was originally published on this site
Powershell is pretty much the scripting language that is in every system administrators bag. One of the problems that I have is that I have installed lots of different Powershell modules on my servers, workstations, VM you name it. Over time you kinda of lose track and end up with differs of different versions of modules on different boxes. As the team I am working in is quite young to scripting we have not really followed a process to write within our scripts to check which version of module people should have installed before executing the script so that the cmdlet will run.
In the meantime you can run this handy command to quickly check what module and the version of module you need to be able to use that particular cmdlet. Remember the same cmdlet may of been updated in a newer version too to have more features.
So on the machine where your script/cmdlet has run successfully run the following command in Powershell;
Get-Command -type cmdlet get-vm | select ModuleName, version
As you can see from the results you can see that the “get-vm” cmdlet on my machine is from the module “VMware.VimAutomation.Core” and is version “22.214.171.12436080”.
On this second example;
Get-Command -type cmdlet start-sleep | select ModuleName, version
The result for cmdlet “start-sleep” is from the module “Microsoft.PowerShell.Utility” and version “126.96.36.199”.
As you can see from the examples you will be able to identify if you have the correct module and version installed on your machine to run a particular cmdlet.