I am just learning the art of "Tool Making" Don Jones book, chapter 4. I am posting this code for review and I hope it passes the formating industry standards, if not tell whats wrong and I will surely fix it:). Now for the bigger question. In the code below I had to alter the books example because I cannot figure out how to make the Get-CimInstance" command except a set of credentials but that is another topic. My main concern and is why the code below will not work. All I am trying to do, is pass a set of credentials to the -credential parameter of that WMI call. It works great until I put it in a "Para" block or am I just doing this wrong. Shouldn't this work, or am I using the "Get-Credential" cmdlet incorrectly. Thanks for all the help I get here, this is a great spot to learn, I will learn this code I promise.
param(
[string]$Credentials = (Get-Credential),
[string]$computerName = (Read-Host 'Enter the PC name')
)
Get-WmiObject -Class Win32_OperatingSystem -ComputerName $computerName -Credential $Credentials