PowerShell for Windows Admins:

Powershell


December 21, 2017  12:08 PM

Windows Updates CIM classes

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
CIM, Powershell, WSUS

When Windows 10 and Server 2016 were released they contained a new CIM namespace - ROOT/Microsoft/Windows/WindowsUpdate This contained a CIM class MSFT_WUOperationsSession that had 2 very useful methods – ScanForUpdates and ApplyApplicableUpdates. These methods enabled you to find and...

December 19, 2017  12:19 PM

Test-Path -PathType

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

Test-Path is a useful cmdlet for testing the validity of a path. You get a True/False return depending on if the path exists or not. There’s also a way to add to the test by determining if the path points to a container (folder) or a leaf (file) using the –PathType parameter. Here’s...


December 16, 2017  9:20 AM

PowerShell v6: #9 Release candidate 2 features

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

A couple of features of PowerShell v6 release candidate 2 need commenting on. Firstly, I was surprised when installing RC 2 on a Windows 10 machine (Insider build) that RC1 was removed. In the past you’ve been able to run numerous versions of PowerShell v6 side-by-side. This has consequences...


December 15, 2017  2:28 PM

PowerShell v6: #8 Release candidate 2

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

Release candidate 2 for PowerShell v6 is available for download from - https://github.com/PowerShell/PowerShell/releases One worrying point is the the OpenSSH implementation...


December 13, 2017  9:51 AM

Using the Where method

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

You don’t usually see people using the where method. A recent question on the forums highlighted using the where method. PowerShell deals in collections and will automatically create a collection of objects if the are multiple objects returned for instance $procs = Get-Process Iterating...


December 6, 2017  9:19 AM

PowerShell v6: #7 Module paths

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

There is a very significant gap between the functionality available in PowerShell v6 as opposed to PowerShell v5.1. In part this is due to the underlying version of .NET but mainly to the defined module paths in the two versions. In PowerShell v5.1 I have: PS> $env:PSModulePath -split...


December 5, 2017  3:23 PM

PowerShell v6: #6 Windows compatibility

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

PowerShell v1 through v5.1 have been based on the full .NET framework. PowerShell v6 is based on .NET core which is a cross platform subset of .NET that’s available for Windows, Linux and mac. This has meant that Powershell v6 on Windows is a poor relation of PowerShell v5.1 in terms of the...


December 2, 2017  4:52 AM

Hyper-V VM start time

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Hyper-V, Powershell

Its fairly easy to see how long a VM has been running – but how do you know the Hyper-V VM start time? In Hyper-V the VM uptime is easy to find

PS> Get-VM | where State -eq 'Running'

Name        State CPUUsage(%) MemoryAssigned(M) Uptime          Status             Version
----   ...


November 29, 2017  10:21 AM

Get Folder sizes

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Powershell

One problem that comes up quite often is how do you get folder sizes. One option is use Measure-Object but the problem with that approach is that its going to be a pretty slow process if you have a lot of folders. PowerShell doesn't have a method of directly getting the folder size and you have to...


November 27, 2017  12:10 PM

Get an AD user’s manager

Richard Siddaway Richard Siddaway Profile: Richard Siddaway
Active Directory, Powershell

Interesting question on the forum about finding the manager for a given user in AD – assuming the Manager field is populated of course. If you’ve not worked with the AD cmdlets this is a good introduction to some of their quirks. This is how you get an AD user’s manager. You need the...


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: