Kind PRTG users,
i am trying to build a script to show me the enabled users in a active directory. i use the following command: (get-aduser -filter *|where {$_.enabled -eq "True"}).count this wil give me a value like 178. But when i put the script underneath together it wont work. I get a The returned json does not match the expected structure (Invalid JSON.). (code: PE231) error. I also get this with another script about windows backup. What is wrong with my script?
$value = (get-aduser -filter *|where {$_.enabled -eq "True"}).count <prtg> <result>” <channel>usersenabled</channel>” <value>$value</value>” <LimitMaxError>200</LimitMaxError>” <LimitMode>180</LimitMode>” </result>”> </prtg> when i look at the log it gives me the following: The term 'get-aduser' is not recognized as the name of a cmdlet, function, scri pt file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\activeuser sAD.ps1:1 char:21 + $value = (get-aduser <<<< -filter *|where {$_.enabled -eq "True"}).count + CategoryInfo : ObjectNotFound: (get-aduser:String) [], CommandN otFoundException + FullyQualifiedErrorId : CommandNotFoundException The term '<' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\activeuser sAD.ps1:2 char:2 + < <<<< prtg> + CategoryInfo : ObjectNotFound: (<:String) [], CommandNotFoundEx ception + FullyQualifiedErrorId : CommandNotFoundException The term '<' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\activeuser sAD.ps1:3 char:4 + < <<<< result> + CategoryInfo : ObjectNotFound: (<:String) [], CommandNotFoundEx ception + FullyQualifiedErrorId : CommandNotFoundException The term '<' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\activeuser sAD.ps1:4 char:6 + < <<<< channel>usersenabled</channel> + CategoryInfo : ObjectNotFound: (<:String) [], CommandNotFoundEx ception + FullyQualifiedErrorId : CommandNotFoundException The term '<' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\activeuser sAD.ps1:5 char:6 + < <<<< value>$value</value> + CategoryInfo : ObjectNotFound: (<:String) [], CommandNotFoundEx ception + FullyQualifiedErrorId : CommandNotFoundException The term '<' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\activeuser sAD.ps1:6 char:6 + < <<<< LimitMaxError>200</LimitMaxError> + CategoryInfo : ObjectNotFound: (<:String) [], CommandNotFoundEx ception + FullyQualifiedErrorId : CommandNotFoundException The term '<' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\activeuser sAD.ps1:7 char:6 + < <<<< LimitMode>180</LimitMode> + CategoryInfo : ObjectNotFound: (<:String) [], CommandNotFoundEx ception + FullyQualifiedErrorId : CommandNotFoundException The term '<' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\activeuser sAD.ps1:8 char:4 + < <<<< /result> + CategoryInfo : ObjectNotFound: (<:String) [], CommandNotFoundEx ception + FullyQualifiedErrorId : CommandNotFoundException The term '<' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\activeuser sAD.ps1:9 char:2 + < <<<< /prtg> + CategoryInfo : ObjectNotFound: (<:String) [], CommandNotFoundEx ception + FullyQualifiedErrorId : CommandNotFoundException
could this be possible because i run it from a server without any active directory?
Add comment