I have a script which scans given computers in domain for identifying and disables mobile hotspot function in windows 10. Script works properly , but i want to scan all my domain comupters, not only specified.. can anyone help me for adjusting this script?
$username = "domain\administrator" $password = "Your password" $credential = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $password $computers = @("nr1", "nr2", "nr3") foreach($computer in $computers){ $hotspot = Invoke-Command -ComputerName $computer -credential $credential -scriptblock { $hotspot = Get-Service "icssvc" if($hotspot.Status -eq "Running"){ Write-Host "Hotspot is turned on on $computer" -ForegroundColor Red try{ Stop-Service "icssvc" Write-Host "Successfully stopped service on $computer" -ForegroundColor Green }catch{ Write-Host "Unable to stop service on $computer" -ForegroundColor Red } }else{ Write-Host "No Hotspot running on $computer" -ForegroundColor Green } }
Get-ADComputer