PowerShell for Windows Admins:

February, 2014


February 28, 2014  4:44 PM

do and while

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Do you understand the difference between do loops and while loops?  On the surface they appear very similar. £> do{$i++}while($i -lt 10) £> $i 10 £> $i=0 £> while($i -lt 10){$i++} £> $i 10 BUT there is a difference £> $i=11 £> do{$i++}while($i -lt 10) £>...

February 28, 2014  2:33 PM

Automatically create folder for home drive

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

In this post  Bookmark and Share     0 Comments     RSS Feed     Email a friend


February 28, 2014  11:55 AM

File or Folder?

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

This is a common type of use for Get-ChildItem: Get-ChildItem -Path c:\temp However, you could get files or folders returned.  Very often you just want to see the files In PowerShell 1.0 & 2.0 you had to do this: Get-ChildItem -Path c:\temp   | where {-not $_.PSIsContainer} If...


February 27, 2014  4:20 PM

I’m afraid you can’t do that anymore

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

In PowerShell 1.0 you could do this: notepad $proc = Get-WmiObject -Class Win32_Process -Filter "Name='notepad.exe'" $proc.Terminate() To access the methods of the WMI class you had to get a variable representing the instance and call the method. This technique still works in PowerShell...


February 27, 2014  2:21 PM

Learn AD Management in a Month of Lunches–ebook available

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The ebook – PDF format - for Learn AD Management in a Month of Lunches has been published - http://www.manning.com/siddaway3/ If you bought the ebook as part of your MEAP you should be able to down load it – you’ll get or have got an email with the link. The printed version is at the...


February 27, 2014  12:30 PM

PowerShell Summit NA 2014

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The PowerShell Summit is happening in Bellevue (Seattle) – April 28 – 30th.  You will be able to hear, meet and talk to some of the biggest names in PowerShell: - Jeffrey Snover – the inventor of PowerShell - PowerShell Team members - Don Jones - Jason Helmick - Jeff...


February 26, 2014  4:47 PM

Useful storage cmdlets

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Scanning through the Storage module there is a bunch of useful cmdlets – starting with the Get* cmdlets: Get-Command -Module Storage...


February 26, 2014  1:38 PM

Delete all but the last N

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I was asked a question about deleting files from a folder based on age.  The requirement was to delete all but the youngest N files. One solution is a classic PowerShell one-liner. It is actually one PowerShell pipeline though I’ve split it across multiple lines for ease of...


February 25, 2014  4:51 PM

Requires

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

You may have seen this at the top of scripts or modules #Requires –Version 3 This will stop the script running if the PowerShell version is 2.0 or below. Other options are available #Requires –PSSnapin      can be used to force the loading of a snapin #Requires...


February 25, 2014  12:16 PM

Waiting for restart

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Some times you need to reboot a remote machine as part of your process.  PowerShell provides the Restart-Computer cmdlet to perform that task: Restart-Computer -ComputerName server03 If you want you process to pause until the reboot has finished then you add the –Wait...


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: