PowerShell for Windows Admins:

PowerShell


June 25, 2013  1:43 PM

UK PowerShell group



Posted by: Richard Siddaway
PowerShell, User Group

As you are probably aware the UK PowerShell group has been very quiet over the last few months. This has been due to my personal circumstances – hopefully now resolved. I want to re-start the group and was wondering what people wanted. When I started the group 6 years ago we were the only...

June 25, 2013  12:46 PM

The inverse association



Posted by: Richard Siddaway
PowerShell, PowerShell 3, WMI

In my last post I showed how to find the groups of which a local user is a member. A comment was left asking about the inverse relationship. In this case we can just turn the code round. Get-CimInstance -ClassName Win32_Group | foreach { $users = Get-CimAssociatedInstance -InputObject...


June 24, 2013  3:23 PM

WMI association example



Posted by: Richard Siddaway
PowerShell, PowerShell 3, WMI

A question came up on the Powershell.org forum about finding the groups of which local accounts are members You can get account data using Win32_UserAccount Group information is held in Win32_Group. You can see the relationship between users and groups by dumping the Win32_GroupUser...


June 24, 2013  12:04 PM

Touching files



Posted by: Richard Siddaway
File System, PowerShell

Unix has a command called touch that allows you to set the access time on a file. PowerShell doesn’t have a direct equivalent but it is very easy to perform the same task: $date = (Get-Date).AddMonths(-2) Get-ChildItem -Path C:\Teszzt2 -Filter f*.txt | Set-ItemProperty -Name LastWriteTime...


June 23, 2013  3:15 PM

PowerShell.org newsletter



Posted by: Richard Siddaway
PowerShell

At powershell.org we publish a monthly email newsletter. As well as PowerShell related news you get a feature article. These articles are only published through the newsletter and are written by acknowledged PowerShell experts. You can subscribe, for free,...


June 23, 2013  8:21 AM

Clearing Event logs



Posted by: Richard Siddaway
Operating System, PowerShell

I needed to clear some event logs on a test machine. Rather than picking and choosing I’ll clear them all Get-EventLog -List | where {($_.Entries).Count -gt 0} | foreach {Clear-EventLog -LogName $_.Log} The interesting part is the where-object filter in that Entries is a collection of...


June 12, 2013  3:31 PM

Scripting Games – what’s wrong with this



Posted by: Richard Siddaway
PowerShell, Scripting Games

I noticed code like this in quite a few entries in for Event 1 Get-ChildItem -path C:\Application\log -Recurse -Filter *.log | Where-Object{$_.LastWriteTime -lt [DateTime]::Now.Subtract([TimeSpan]::FromDays(90))} | ForEach-Object {…} From the title it should be obvious that there’s...


May 24, 2013  2:00 PM

AD Month of Lunches–Chapter 11 in MEAP



Posted by: Richard Siddaway
Active Directory, Books, PowerShell

The MEAP for AD Management in a Month of Lunches has been extended with the inclusion of chapter 11 – Creating Domain Controllers. www.manning.com/siddaway3 Enjoy


May 21, 2013  3:49 PM

Scripting Games – Filter early again



Posted by: Richard Siddaway
Active Directory, PowerShell, Scripting Games

Grading the scripts in Event 4 and the one thing that jumps out is the amount of unnecessary data being carried through the scripts You were asked for 7 properties off 20 random users Get-ADUser has a –properties parameter. USE it to restrict the properties you return. You don’t NEED all...


May 20, 2013  3:50 PM

Scripting Games – Win32_LogicalDisk or Win32_Volume



Posted by: Richard Siddaway
PowerShell, Scripting Games, WMI

I have heard some discussions recently regarding whether Win32_LogicalDisk or Win32_Volume should be used in the answer to event 3 in the Scripting Games. The problem requires you pull the drive letter, drive size and freespace for local disks on the server. Notice the emphasis – that will be...


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: