During an excellent trip to see a local customer *, it was noted that some of the script examples on the blog were not working as expected. The post we were looking at was the Check Exchange 2013 Schema and Object Information in AD. When the sample commands were copied, the Exchange administrator was not able to immediately use them, even after editing to suit their environment.
The symptoms were actually the same as those in a separate post to Start Exchange Services. An excerpt of that post is shown below:
Get-WmiObject -Class Win32_Service –Filter “startmode=’auto’ and state=’stopped’ and (name > ‘clra’ or name < ‘clr’)”
Get-WmiObject : Invalid query
At line:1 char:14
+ Get-WmiObject <<<< -Class Win32_Service –Filter “startmode=’auto’ and state=’stopped’ and (name > ‘clra’ or name < ‘clr’)”
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
What happened? Its a classic issue when copying code from a formatted blog. In the example below, the top line is what was entered above. The top line does not work. The bottom line will work. What is the difference?
Note that the top line has smart quotes. The bottom line does not.
The code samples were working previously. Back in 2016 the TechNet and MSDN blogs were moved to a WordPress instance, and it looks like the default WordPress behaviour to use smart quotes changed the formatting.
I will see what can be done to address this. In the meantime, please leave a comment on a post that is that has an issue and I will do the necessary to get it correctly formatted.
Cheers,
Rhoderick
* - Let's call that admin "Jake" to protect the innocent.