Category Archives: PowerShell V3

Improving CIM/WMI method discovery

I recently showed how to create a function that could be used to simplify the use of Get-CimClass. In this version I’ve added some features: – parameter validation – namespace – try-catch round getting the class information. This turns the … Continue reading

Posted in CIM, PowerShell and WMI, PowerShell V3, PowerShell v4 | Leave a comment

Discovering CIM/WMI methods and parameters

As you’ve probably gathered I spend a lot of time working with, and investigating, CIM (WMI) classes. CIM and WMI will be treated as synonymous for these articles. If you want to discover the methods available on a CIM class … Continue reading

Posted in CIM, PowerShell and WMI, PowerShell V3, PowerShell v4 | Leave a comment

Module confusion–what’s really in PowerShell 3 and 4

If I run Get-Module –ListAvailable on my Windows 8.1 system (PowerShell 4.0) I find a total of 58 modules installed in $pshome\modules i.e. C:\windows\system32\WindowsPowerShell\v1.0\Modules These are the modules installed as part of PowerShell. Right? Wrong? Compare this with a Windows … Continue reading

Posted in PowerShell V3, PowerShell v4 | Leave a comment

End of PowerShell Jobs week

My series on PowerShell Jobs for the Scripting Guy blog has finished.  The set of articles is: Jobs week 1 : Introduction to PowerShell jobshttp://blogs.technet.com/b/heyscriptingguy/archive/2014/03/02/powershell-jobs-week-introduction-to-powershell-jobs.aspx http://blogs.technet.com/b/heyscriptingguy/archive/2014/03/02/powertip-control-job-starts-with-powershell.aspx Jobs week 2 : WMi and CIM jobshttp://blogs.technet.com/b/heyscriptingguy/archive/2014/03/03/powershell-jobs-week-wmi-and-cim-jobs.aspx http://blogs.technet.com/b/heyscriptingguy/archive/2014/03/03/powertip-use-powershell-to-keep-job-data.aspx  Jobs week 3 : Remote Jobshttp://blogs.technet.com/b/heyscriptingguy/archive/2014/03/04/powershell-jobs-week-remote-jobs.aspx http://blogs.technet.com/b/heyscriptingguy/archive/2014/03/04/powertip-use-powershell-to-find-job-help.aspx  Jobs … Continue reading

Posted in Powershell Basics, PowerShell V2, PowerShell V3, PowerShell v4 | Leave a comment

I’m afraid you can’t do that anymore

In PowerShell 1.0 you could do this: notepad$proc = Get-WmiObject -Class Win32_Process -Filter “Name=’notepad.exe’”$proc.Terminate() To access the methods of the WMI class you had to get a variable representing the instance and call the method. This technique still works in … Continue reading

Posted in CIM, PowerShell and WMI, Powershell Basics, PowerShell V3, PowerShell v4 | Leave a comment

Win32_OperatingSystem examples

The Win32_ComputerOperatingSystem class can provide a good deal of information about the OS installed on your machines. These examples are converted from those presented here: http://msdn.microsoft.com/en-us/library/aa394596%28v=vs.85%29.aspx # ServicePack versionGet-CimInstance -ClassName Win32_OperatingSystem | select ServicePackMajorVersion, ServicePackMinorVersion # install date of OSGet-CimInstance … Continue reading

Posted in CIM, PowerShell V3, PowerShell v4 | Leave a comment

Win32_Process examples–running applications

You can see the running processes on a local or remote machine using Get-Process. Alternatively you can use Win32_Process: Get-CimInstance -ClassName Win32_Process | select Name, ProcessID, Threadcount, PageFileUsage, PageFaults, WorkingSetSize | Format-Table –AutoSize You can use the –ComputerName or –CimSession … Continue reading

Posted in CIM, PowerShell V3, PowerShell v4 | Leave a comment

Win32_Process examples–test command line

To see the command lines that have been used when processes are started is simple one liner: Get-CimInstance -ClassName Win32_Process | select Name, CommandLine If you want to investigate specific processes use the –Filter parameter to restrict the processes

Posted in CIM, PowerShell V3, PowerShell v4 | Leave a comment

Win32_Examples–start application in hidden window

This one is interesting as I’d tried doing this a while back and failed.  Starting a process with Win32_Process is straightforward but controlling the process – such as starting in a hidden window wasn’t working. This is how you do … Continue reading

Posted in CIM, PowerShell V3, PowerShell v4 | Leave a comment

Win32_Process examples–running scripts

Back in the day when all we had was VBScript you could run scripts through the command line (cscript) or you would get a more graphical interface (wscript).  One of the examples at http://msdn.microsoft.com/en-us/library/aa394599(v=vs.85).aspx shows how to detect running scripts. … Continue reading

Posted in CIM, PowerShell and WMI, PowerShell V3, PowerShell v4 | Leave a comment