I’ve already gone over OneGet and its inclusion to Windows Management Framework (WMF) 5, but what else was added with PowerShell V5 that everyone can use?
Besides OneGet, there are some improvements to Desired State Configuration (DSC) to include performance improvement, bug fixes and other general optimizations.
L2 Network Switch Management
The other “big ticket item” with V5 is the ability to now manage L2 Network Switches. The module, NetworkSwitch, contains 19 functions which are available to manage a switch. Those functions are listed below:
I do not have a switch that would work with this on me, so I will point to the following article that shows a little more information about using this module.
New Cmdlets
Besides that, there are a couple of new cmdlets that I have found which you can use:
Get-ItemPropertyValue
This cmdlet lets you get down to the actual value of an item. Very useful for working in the registry.
Let’s look at one of the properties and see what is available.
Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\.NETFramework
Ok, I want to see the value of InstallRoot.
Get-ItemPropertyValue -Path HKLM:\SOFTWARE\Microsoft\.NETFramework -Name InstallRoot
Using this cmdlet, we can now get the value under the property. Pretty cool, but oddly enough, there is no Set-ItemPropertyValue (or a Remove-ItemPropertyValue). Maybe in the next preview release.
Debug-Job
This is an interesting cmdlet that has been added to the latest version of PowerShell.
The only parameters that it has are concerning the way to attach to an existing PSJob. Let me kick off a job so we can try this out.
Start-Job -Name Demo -ScriptBlock { While ($True) { For ($i=0;$i -lt 10; $i++) { Write-Verbose "Iteration: $i" -Verbose $i Start-Sleep -Seconds 1 } Write-Verbose "Resetting" -Verbose } }
Per the nature of the job, we cannot see anything. Let’s see what happens when we hook up Debug-Job to our currently running job.
Debug-Job -Name Demo
What I notice immediately is that it runs through all of the streams that have already happened prior to getting to the final point of actually going into the PSJob via the debugger.
Looking at the help, I can see what my available debugging options are:
I can explore the job just like I would when I explore a script via the *-PSBreakPoint cmdlets in the console or ISE.
Typing (q)uit will completely stop the job and exit the debugger. Instead, I want to use ( c )ontinue instead.
Now we can see that the operation will continue on and provide the status of the streams had used in the job. Unfortunately, there is not a way to just exit the debugger without the output continuing to run. I tried Exit and it behaved much like using Continue. Only a Ctrl+C would stop it displaying the debugging info and still keep the background job running. Possibly a bug.
To finish out, I did find a few more “new cmdlets”, but believe that these are actually bugs with the new release.
There are an additional 11 functions for ServerManagerTasks module which are basically the same functions (minus the “SM” prefix on the noun) which do not work at all and actually act as though they do not exists
Then there is the Get-StreamHash function which serves as a helper function for Get-FileHash but was made public. It doesn’t work by itself even though I tried to match what it was looking for in the parameters. It still needed a variable which was available in Get-FileHash.
I posted Connect items here on those to make sure that they are resolved by the time the main release is available.
So that is it for now. As I find new things with this and the future preview releases, I will be sure to write about them to share what I have found. If you happen to find something that I missed, but sure to drop a line in the comments!
Pingback: More New Stuff in PowerShell V5: Expand and Compress Archive Cmdlets | Learn Powershell | Achieve More
Pingback: PowerShell v5 | Giblabs