PowerShell for Windows Admins


October 27, 2013  10:48 AM

More Scripting Guy posts

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I’ve had some more articles posted on the Scripting Guy blog

http://blogs.technet.com/b/heyscriptingguy/archive/2013/10/27/the-admin-s-first-steps-local-group-membership.aspx

http://blogs.technet.com/b/heyscriptingguy/archive/2013/10/20/powertip-find-members-of-critical-groups-with-powershell.aspx

http://blogs.technet.com/b/heyscriptingguy/archive/2013/10/20/the-admin-s-first-steps-empty-groups.aspx

Enjoy

October 14, 2013  2:22 AM

Sunday’s Scripting Guy blog

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I had another post in my Admin’s First Steps series on the Scripting Guy blog yesterday –

http://blogs.technet.com/b/heyscriptingguy/archive/2013/10/13/powertip-use-poweshell-to-start-service-on-remote-machine.aspx

http://blogs.technet.com/b/heyscriptingguy/archive/2013/10/13/the-admin-s-first-steps-discovering-shares.aspx

Enjoy


October 11, 2013  11:48 AM

Summit 2014 Speaker list “leak”

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Possible speakers at the PowerShell Summit in April 2014.

http://powershell.org/wp/2013/10/10/leak-powershell-summit-na-2014-speakers/

If you want to see, hear and talk to these PowerShell experts – the PowerShell summit is unlike most other conferences as the speakers are available

Now is the time to register – http://powershell.org/wp/community-events/summit/powershell-summit-north-america/summit-registration/

Some places will be reserved for the New Year for late bookings but I don’t think there’ll be many. We sold out last year & had a brilliant 3 days. This is going to be better


October 10, 2013  1:33 PM

Testing Service Health

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Two new posts from me on the Scripting Guy blog

http://blogs.technet.com/b/heyscriptingguy/archive/2013/10/10/powertip-change-output-object-property-names-with-powershell.aspx

http://blogs.technet.com/b/heyscriptingguy/archive/2013/10/10/the-admin-s-first-steps-testing-service-health.aspx

Enjoy


October 9, 2013  2:05 PM

AD Management MEAP v 11

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

The next MEAP for AD Management in a Month of Lunches is available from Manning – www.manning.com/siddaway3

This adds chapter 20 on maintaining and monitoring AD together with appendix A on searching AD

Enjoy


October 8, 2013  2:48 PM

ADs 1000 object limit

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

By default when you query AD using a script or cmdlet you won’t get more than 1000 objects returned. If your AD contains 4000 users and you run

Get-ADuser –filter *

You’ll still only get the first 1000 users returned.

This is by design to prevent you accidentally unleashing the “query from hell” and grinding your poor domain controller into the ground.

Of course if you only have 900 users you’ll never see a problem.

You can get a bigger result set using the ResultSetSize parameter.

Set it to a value bigger than you expect and you’ll be fine.

The documentation says that using a value of $null (which is supposedly default) will return all objects that match you filter. I need to test but I don’t think that’s right


October 7, 2013  1:10 PM

Desired State Configuration

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Desired State Configuration is the headline item in PowerShell 4.0

Steven Murawski has started a series of posts on PowerShell.org. The first two posts are available

http://powershell.org/wp/2013/10/02/building-a-desired-state-configuration-infrastructure/

http://powershell.org/wp/2013/10/03/building-a-desired-state-configuration-pull-server/

More to come


October 5, 2013  5:59 AM

Common mistakes–size constants

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

I can’t count the number of times I’ve seen something like this:

Get-WmiObject -Class Win32_LogicalDisk -Filter {DriveType = 3} |
select @{N=’Capacity’; E={[math]::Round(($_.Size / 1073741824), 2)}}

What’s wrong this?

The use of 1073741824 – in case you don’t recognise the number its 1 gigabyte.

Wouldn’t you prefer to do this

Get-WmiObject -Class Win32_LogicalDisk -Filter {DriveType = 3} |
select @{N=’Capacity’; E={[math]::Round(($_.Size / 1gb), 2)}}

That’s right divide by 1 gigabyte.

PowerShell recognises the main sizes you’ll be using – from KB to PB (petabyte)

1kb, 1mb, 1gb, 1tb, 1pb |
foreach {
“{0,16}” -f $psitem
}

1024
1048576
1073741824
1099511627776
1125899906842624

Which would you prefer to type 1pb or 1125899906842624 ?

Using the size constants is less prone to error and also reminds you of what you are trying to achieve.


October 5, 2013  5:41 AM

Common mistakes–filtering

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Which of these should you use

Get-WmiObject -Class Win32_LogicalDisk | where DriveType -eq 3

or

Get-WmiObject -Class Win32_LogicalDisk -Filter {DriveType = 3}

They both give the same results after all.

Against a remote machine the first one took 640 milliseconds and the second took 245 milliseconds.

The reason for the difference is that the first command pulls back information on all logical disks – and then filters. The second on pulls back information on drive type 3 (local hard disks)

The 395 milliseconds difference doesn’t sound much and against 1 machine is negligible. No span that across hundreds or thousands of machines and you get a significant impact.

Always filter the data down as soon as you can – preferably at source.


October 3, 2013  2:00 AM

Scanning event logs

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

My post on scanning event logs on multiple machines using a workflow went live on the Scripting Guy blog yesterday –

http://blogs.technet.com/b/heyscriptingguy/archive/2013/10/02/the-admin-s-first-steps-scan-multiple-event-logs.aspx


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: