Hi - I am by no means a powershell regular user, but recently there has become a requirement for me to implement some PS into my work.
I am trying to safely escape an if statement, as per noted security requirements:
The original statement:
if (Get-WmiObject Win32_UserAccount -Filter "Name=\'guest12345678\'") { exit 1 }
The statement once escaped;
if` `$(Get-WmiObject` Win32_UserAccount` -Filter` \\`\"Name=`'guest12345678`'\\`\")` {` exit` 0` }
The error I am getting:
The module 'Get-WmiObject Win32_UserAccount -Filter could not be loaded. For more information, run 'Import-Module Get-WmiObject Win32_UserAccount -Filter '.
Debug: At line:1 char:6
Debug: + if` (Get-WmiObject` Win32_UserAccount` -Filter` \`"Name=`'guest123456 ...
Debug: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Debug: + CategoryInfo: ObjectNotFound: (Get-WmiObject W...uest12345678'\":String) [], CommandNotFoundException
Debug: + FullyQualifiedErrorId : CouldNotAutoLoadModule
As mentioned im by no means a regular user, so I must clearly be missing something Has anyone any ideas? I appreciate any help with this!