Articles

PowerShell articles, tutorials, and guides from community experts.

Richard Siddaway

Putting the date in a file name

I often need to create file names that include the date & time the file was created in the name. I"™ve come up with all sorts of ways to do but this I think is the simplest. I want the date in this format: year-month-day-hour-minute-second. In other words a format that is easily sortable. I discovered that if you convert a data to a string there is a formatter that does most of the work for you.

Richard Siddaway

PowerShell excerpt week

The Scripting Guy is running a series of excerpts from the PowerShell books published by Manning. Today is PowerShell in Practice http://blogs.technet.com/b/heyscriptingguy/archive/2013/04/03/excel-spreadsheets.aspx Check out the deals all this week on Manning PowerShell books

Don Jones
Scripting Games

2013 Scripting Games Competitor Guide (for the Public, too!)

Our Competitor Guide is now online - you can download it here: 2013 Competitor Guide We’re doing things a bit differently this year. We’ll be engaging the overall PowerShell community for numeric grades - and those doing the grading have an awesome chance to win some great prizes! Our expert Judges will be focused on commentary, making this even more of a learning event. Download the Guide and see what’s in store - the Games are scheduled to start the week of April 22nd.

Richard Siddaway

MVP renewal 2013

This afternoon I received the email notifying me that my MVP award had been renewed for another year. Thank you to Microsoft ““ I regard the award as a great honour. And thank you to the PowerShell community ““ its a great place to be

Richard Siddaway

Shutting down a remote computer

PowerShell provides the Stop-Computer cmdlet for closing down a remote machine. I find this especially useful in my virtual test environment. I"™ll have several machines running but won"™t necessarily have logged onto them. Using Stop-Computer means that I can shut them down cleanly without the hassle of logging onto them. In modern Windows systems you have to explicitly enable remote WMI access through the Windows firewall. Stop-Computer uses WMI. If the WMI firewall ports aren"™t enabled you can"™t use Stop-Computer.

Richard Siddaway

CIM cmdlets

The CIM cmdlets are found in the CIMcmdlets module. Get-Command -Module CimCmdlets produces this list of names. I"™ve added some information on the tasks they perform Get-CimAssociatedInstance is for working with WMI associated classes Get-CimClass is for discovering the properties and methods of a WMI class Get-CimInstance is analogous to Get-WmiObject Get-CimSession Invoke-CimMethod is analogous to Invoke-WMIMethod New-CimInstance can be used for creating a new WMI instance in certain circumstances

Richard Siddaway

WMI vs CIM

An email debate yesterday regarding the use of the CIM cmdlets (new in PowerShell 3) vs the WMI cmdlets made me realise that other people are probably wondering the same thing, The question is really part of a the semi-philosophical debate about when you should adopt new technology. In the case of the WMI/CIM cmdlets the resolution is fairly straightforward. If you are using PowerShell v2 you have to use the WMI cmdlets.

Richard Siddaway

PowerShell 3 SDK samples

A sample pack for the SDK is now available - see http://blogs.msdn.com/b/powershell/archive/2013/03/17/windows-powershell-3-0-sample-pack.aspx

Richard Siddaway

Network Adapters"“Disable/Enable

Last time we saw the Get-NetAdapter cmdlet from the NetAdapter module PS> Get-NetAdapter | ft Name, InterfaceDescription, Status -a Name InterfaceDescription Status —- ——————– —— Ethernet NVIDIA nForce 10/100/1000 Mbps Ethernet Up WiFi Qualcomm Atheros AR5007 802.11b/g WiFi Adapter Up If you look in the module you also find Disable-NetAdapter & Enable-NetAdapter PS> Disable-NetAdapter -Name Wifi -Confirm:$false PS> Get-NetAdapter | ft Name, InterfaceDescription, Status -a Name InterfaceDescription Status —- ——————– —— Ethernet NVIDIA nForce 10/100/1000 Mbps Ethernet Up WiFi Qualcomm Atheros AR5007 802.