You are on page 1of 2

Powershell

Saturday, November 20, 2021


4:00 AM
------------Reiniciar computadora
remoto------------------
Shutdown /m \\namecomputer /t <segundos> /r
 
------------Setup de instalador de
windows------------------
Setup.exe /auto upgrade /dynamicupdate disable
/migratedrivers all /quiet /noreboot
 
 
------------scipt copiar archivos
remoto------------------
 
#remote machines list
$machines= Get-Content -Path "C:\temp\workstations.txt"
foreach ($onemachine in $machines)
{
Write-Host "Currently the script is copying files on"
$onemachine
Copy-Item -Path "\\10.49.168.123\e$\ML210303098\Apps\
apex556.msi" -Destination "\\$onemachine\c$\" -Recurse
}
 
------------Version de windows de forma
remota------------------
 
Get-Content "C:\computers.txt" | ForEach-Object{
$os_name=$null
$os_version=$null
$errorMsg=''
Try { $os_name = (Get-WmiObject Win32_OperatingSystem -
ComputerName $_ ).Caption }
 
Catch { $errorMsg=$_.Exception.Message }
 
if(!$os_name){ $os_name = "The machine is unavailable
$errorMsg" $os_version = "The machine is unavailable" }
 
else{ $os_version = (Get-WmiObject
Win32_OperatingSystem -ComputerName $_ ).Version }
 
New-Object -TypeName PSObject -Property @{ ComputerName
= $_ OSName = $os_name OSVersion = $os_version }
 
} | Select ComputerName,OSName,OSVersion |
Export-Csv "C:\OS_Details.csv" -NoTypeInformation -
Encoding UTF8
 
------------iniciar cmd en remota------------------
 
.\psexec \\HOSTNAME cmd
 
------------crear ruta persistente para
red------------------
 
ROUTE PRINT --Mostrar tabla de rutas.
route -p ADD [ IP ] MASK 255.255.255.0 [ DEFAULTGATEWAY ]
 
-------------------------------------------------------
------
$ping=New-Object System.Net.NetworkInformation.ping
 
1..10 | % { $ping.send("172.25.245.$_") | select address, status }
 
[system.net.dns]::gethostentry('192.168.1.50')
 
$ip = "10.49.216"
var islist= 1..254 | %{if ((test-connection "10.49.216.$_" -count 1 -quiet)) {write-host -f Green "$ip`.$_"}}
if (islist){ }
 
1..50 | %{if ((test-connection "10.49.216.$_" -count 1 -quiet))
{[system.net.dns]::gethostentry([IPAddress]"$ip`.$_")}}
 
 
 

You might also like