Tags » Powershell-basics

Splatting and Default parameters

One thing you don’t hear much about is default parameters.

Consider this

Get-CimInstance -ClassName Win32_LogicalDisk -Filter “DeviceId = ‘C:'”

A pretty standard use of CIM. … 190 more words

Powershell Basics

Out of Process

One thing I’ve been seeing come up a lot recently is the problem of modules and cmdlets cot being available when jobs and workflows are executed even though the module has been specifically loaded into PowerShell. 68 more words

Powershell Basics

WMI wildcards and filtering

A question on the forum asking about filtering WMI results raises a number of interesting points.

The user wanted to pass a computername and a filter term to pull product information from remote machines. 156 more words

PowerShell And WMI

WMI cmdlets and credentials

If you’re working with the WMI cmdlets and need to pass credentials you’ll end up with a statement something like this

Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer -Credential $cred… 323 more words

PowerShell And WMI

-in operator

As an alternative to the –contains operator you can use the –in operator

Repeating the tests from the previous post on –contains

PS> $primes = 1,3,5,7,11,13,17,19,23,29,31,37,41,43,47… 30 more words

Powershell Basics

-contains operator

Sometimes you may want to test if a value is in a collection of values

For instance

$primes = 1,3,5,7,11,13,17,19,23,29,31,37,41,43,47

if you want to test if 7 is a member of the collection… 10 more words

Powershell Basics

Testing connectivity before Invoke-Command

A question on the forum asked about testing if a remote machine could be reached before using Invoke-Command against it.

The usual way to test if you can reach a remote machine is to ping it… 133 more words

Powershell Basics