How do I do foreach loop with a where clause for a multidimensional array in Powershell?

For example $people = @( @(‘adam’, ’24’, ‘M’) @(‘andy’, ’20’, ‘M’) @(‘alex’, ’30’, ‘M’) @(‘ava’, ’25’, ‘F’) ) foreach($person in $people | where ($person[1] -lt ’25’) -and ($person[2] -eq ‘M’)) and this should select adam and andy… >Solution : The syntax you should use for your Where-Object statement would be: $people = @( @(‘adam’, ’24’,… Read More How do I do foreach loop with a where clause for a multidimensional array in Powershell?

How would you programmatically report which Windows Services are not running?

Given: PowerShell 5.1 or above Cmdlet Get-Service Windows OS Windows Services How would you programmatically report if a Window Services is Stopped? >Solution : If you want to start them all, use the Where-Object cmdlet to filter the list of services so you only get those that: Are not running, and Are not disabled Then… Read More How would you programmatically report which Windows Services are not running?

Powershell running invoke-command on several servers using -Asjob but log completion log locally

I am trying to run a powershell script that installs some software on a bunch of remote servers. I am using the -Asjob option to run them synchronously. I’m also using for loop to run the remote commands on each server, but i want to write a "Done" log file locally where i am running… Read More Powershell running invoke-command on several servers using -Asjob but log completion log locally

How to output IP address to file with powershell "Write-Output" command without null values

I’m trying to write an IP address (It’s just a random test IP I used) to a file using powershell’s Write-Output and it’s writing the IP address to the file but adding null values after every character. Is there any way to do this properly, without the null characters? >Solution : I’m not sure why,… Read More How to output IP address to file with powershell "Write-Output" command without null values