Powershell
Saturday, November 20, 2021
4:00 AM
------------Reiniciar computadora
remoto------------------
Shutdown /m \\namecomputer /t <segundos> /r
------------Setup de instalador de
windows------------------
[Link] /auto upgrade /dynamicupdate disable
/migratedrivers all /quiet /noreboot
------------scipt copiar archivos
remoto------------------
#remote machines list
$machines= Get-Content -Path "C:\temp\[Link]"
foreach ($onemachine in $machines)
{
Write-Host "Currently the script is copying files on"
$onemachine
Copy-Item -Path "\\[Link]\e$\ML210303098\Apps\
[Link]" -Destination "\\$onemachine\c$\" -Recurse
}
------------Version de windows de forma
remota------------------
Get-Content "C:\[Link]" | ForEach-Object{
$os_name=$null
$os_version=$null
$errorMsg=''
Try { $os_name = (Get-WmiObject Win32_OperatingSystem -
ComputerName $_ ).Caption }
Catch { $errorMsg=$_.[Link] }
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 [Link] [ DEFAULTGATEWAY ]
-------------------------------------------------------
------
$ping=New-Object [Link]
1..10 | % { $[Link]("172.25.245.$_") | select address, status }
[[Link]]::gethostentry('[Link]')
$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))
{[[Link]]::gethostentry([IPAddress]"$ip`.$_")}}