PowerShell for IT Professionals [#15] – Scripting part 2 – IF and psobject
In this lesson we carry on writing the scripting by gathering requirements and putting them together as comments in code.
Then we will retrieve OS information with the help of WMI and display it on the screen with Write-Host.
Although using Write-Host is easy to use, it doesn’t really allow us to do very much e.g. we cannot export information to the CSV, therefore we change it and start using custom PSObject – that way our script will start returning information like a regular PowerShell command.
Finally, we will use an IF statement to decide whether the OS we are checking is a server.