Based on the following .ps1 program. Write a program that checks for the user "shu", if not present it will create it.
Write-Host "checking users"$testUser="hgallo"
$checkUser = Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount='True'" | Select-String -Pattern $testUser
if($checkUser -ne $null) {
Write-Host "user $testUser found"
} else {
Write-Host "user $testUser not found"
}
this is my homework and im not good at coding guys can you help me pleases.
Here is the error Select-String
:
Cannot bind argument to parameter 'Pattern' because it is null.
At line:1 char:107
+ $checkUser=Get-WmiObject -Class Win32_UserAccount -Filter "LocalAccount='True'" | select-string -pattern <<<< $tes tUser
+ CategoryInfo : InvalidData: (:) [Select-St