-1

I am using the following script to retrieve Windows Defender status remotely.

$password = ConvertTo-SecureString “myPassword” -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential (“myUserNamer”, $password)
$sessionOption = New-CimSessionOption -Protocol WsMan
$session = New-CIMSession -ComputerName myMachineName -Credential $credentials -SessionOption
Get-MpPreference -CimSession $session

However, I am quite new to PowerShell scripting and related protocols. Is this the best way of retrieving this information when I may have to run it over hundreds of computers?

whoami
  • 1,689
  • 3
  • 22
  • 45

1 Answers1

1

Does it need to be for all the machines or selected ones?

For example: You could run a remote session on the machine you need and then run the command.

Enter-PSSession [VMname]
Get-MpComputerStatus

Replace [VMname] with the name of the VM/Computer you're looking for.

Enter-PSSession Computer-01
Get-MpComputerStatus

If that's what you're looking for.

Minkulai
  • 64
  • 6
  • I need to run it on multiple machines but would like to run it in parallel and asynchronously if possible. Can you please elaborate on what will be the advantages of the approach you suggested vs what I used? – whoami Jan 09 '21 at 04:11