Получаем список серверов или пк
Get-ADComputer -filter * -SearchBase 'DC=adminbd,DC=adminbd,DC=ru' | select -ExpandProperty name | sc c:\comps.txt
Get-ADComputer -filter * -SearchBase 'DC=adminbd,DC=adminbd,DC=ru' | select -ExpandProperty name | sc c:\comps.txt $computer = "c:\comps.txt" foreach ($computerName in (Get-Content $computer)) { If (Test-Connection -ComputerName $computerName -Count 2 -Quiet) { Write-Host "Пытаюсь проверить компьютер на пакеты ping"; Invoke-Command -ComputerName $computerName -ScriptBlock { #$credential = Get-Credential -UserName "Администратор" -Message "Введите новый пароль"; $UserName="Admin" $Password=convertto-securestring "пароль" -asplaintext -force If ($UserName -eq $null) { Write-Warning "The username and/or the password is empty! I quit."; Exit; } Set-LocalUser -Name $UserName -Password $Password; } } Else { Write-Warning "Компьютер не отвечает на Ping."; } }
Смена пароля на старых windows ниже 2016
#Get-ADComputer -filter * -SearchBase 'DC=adminbd,DC=adminbd,DC=ru' | select -ExpandProperty name | sc c:\comps.txt $computer = "c:\comps.txt" foreach ($computerName in (Get-Content $computer)) { If (Test-Connection -ComputerName $computerName -Count 2 -Quiet) { Write-Host "Пытаюсь проверить компьютер на пакеты ping"; Invoke-Command -ComputerName $computerName -ScriptBlock { #$credential = Get-Credential -UserName "Администратор" -Message "Введите новый пароль"; $UserName="Administrator" #$Password=convertto-securestring "3<KksHhnG}59-<" -asplaintext -force [adsi]$user = "WinNT://./Administrator"; [adsi]$localPC = "WinNT://." #$localPC.Children | where {$_.Class -eq "user"} | ft name, description –auto If ($UserName -eq $null) { Write-Warning "The username and/or the password is empty! I quit."; Exit; } $user.SetPassword("пароль") } } Else { Write-Warning "Компьютер не отвечает на Ping."; } }
Similar Posts:
- Как найти включённого локального администратора на серверах в AD.
- Как удалить из папки файлы с серверов ad им перезапустить службу.
- Как сбросить терминальные сессии на терминальной ферме RDS windows 2012-2016 без прав администратора
- Как настроить ilo через powershell hpeilocmdlets
- Как завершить сессию на всех серверах в локальной сети.