Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $username = "domainadministrator"
- $password = "Your password"
- $credential = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $password
- $computers = Get-ADComputer -Filter *
- foreach($computer in $computers){
- $computerDNS = $computer.DNSHostName
- $hotspot = Invoke-Command -ComputerName $computerDNS -credential $credential -scriptblock {
- $hotspot = Get-Service "icssvc"
- if($hotspot.Status -eq "Running"){
- Write-Host "Hotspot is turned on on $env:computername" -ForegroundColor Red
- try{
- Start-Service "icssvc"
- Write-Host "Successfully stopped service on $env:computername" -ForegroundColor Green
- }catch{
- Write-Host "Unable to stop service on $env:computername" -ForegroundColor Red
- }
- }else{
- Write-Host "No Hotspot running on $env:computername" -ForegroundColor Green
- }
- }
- }
Add Comment
Please, Sign In to add comment