header image

Archive for July, 2014

Saw a question on the forums about formatting all disks but the C: drive.  Assuming you ever need to do such a destructive activity you might want think about ths sort of approach Get-CimInstance -ClassName Win32_Volume -Filter "DeviceId != ‘C:’" | foreach { Invoke-CimMethod -whatif -InputObject $psitem -MethodName Format -Arguments @{    ClusterSize = 4096 […]

under: PowerShell and WMI

Formatting disks

Posted by: | July 13, 2014 | No Comment |

Saw a question on the forums about formatting all disks but the C: drive.  Assuming you ever need to do such a destructive activity you might want think about ths sort of approach Get-CimInstance -ClassName Win32_Volume -Filter “DeviceId != ‘C:’” … Continue reading →

under: PowerShell and WMI

Manning are offering 40% off everything – print & ebooks – www.manning.com. They have a very extensive set of PowerShell books – now would be the time to add to your collection

under: Active Directory, Books, PowerShell original

I much prefer the CIM cmdlets for accessing remote machines. The WMI cmdlets use DCOM which is firewall unfriendly and can often be unavailable of a server – cue the dreaded RPC server is unavailable error messages. By contrast the CIM cmdlets use WSMAN. For one off access to a remote machine use the computername […]

under: PowerShell and CIM, PowerShell and WMI, PowerShell V3, PowerShell v4

Registration will open next Tuesday (15th July) – that’s less than 1 week

under: PowerShell original, PowerShell Summit

Finding a CIM class

Posted by: | July 7, 2014 | No Comment |

I was investigating something on my disks and started to look at the partitions: £> Get-CimInstance -ClassName Win32_Partition Get-CimInstance : Invalid class At line:1 char:1 + Get-CimInstance -ClassName Win32_Partition + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : MetadataError: (root\cimv2:Win32_Partition:String) [Get-CimInstance], CimException     + FullyQualifiedErrorId : HRESULT 0x80041010,Microsoft.Management.Infrastructure.CimCmdlets.GetCimInstanceCommand OK so my memory isn’t what it was and I […]

under: PowerShell and WMI, PowerShell V3

The CIM and WMI cmdlets both provide a way to use the methods on CIM classes namely Invoke-CimMethod and Invoke-WmiMethod. The cmdlets are very similar in operation. $vol = Get-WmiObject -Class Win32_Volume -Filter "DriveLetter = ‘D:’" Invoke-WmiMethod -InputObject $vol -Name Chkdsk -ArgumentList $false, $true, $true, $false, $false, $false   The argumenst list isn’t very informative […]

under: PowerShell V3, PowerShell v4

Consider this workflow workflow chkpt1 { Get-Process foreach ($x in 1..20){ $x } }   It will dump out the process information then output the numbers 1 to 20.  Not a particularly enlightening workflow but it forms  a nice basis for demonstrating checkpoints. A checkpoint saves the state and data in the workflow. If the […]

under: PowerShell V3, PowerShell v4

and finally

Posted by: | July 3, 2014 | No Comment |

If you’re old enough and seen UK TV you’ll recognise the title but this post is about using try – catch blocks. Using try-catch this is a fairly normal construction try { Get-CimInstance -ClassName Win32_LogicalDisk  -ErrorAction Stop } catch { Throw "something went wrong" } The number of commands within the try block should be […]

under: PowerShell Basics

CIM or WMI?

Posted by: | July 2, 2014 | No Comment |

Working with WMI became a whole easier when PowerShell came on the scene. If you ever spent hours typing all of the Echo commands that were required with VBScript to produce output you’ll be aware of what I mean.  There are still a few awkward areas in the WMI cmdlets. One of the most awkward […]

under: PowerShell and WMI

« Newer Posts - Older Posts »

Categories