Archive for 2011

Working with multiple computers in Bash

Working with multiple computers in Powershell is absurdly easy using the Get-Content cmdlet to read computer names from a text file. It’s as easy as this… ?View Code POWERSHELL$a = Get-Content "C:\Scripts\Test.txt"   foreach ($i in $a) {$i + "`n" + "=========================="; Get-WMIObject Win32_BIOS -computername $i} As I’m doing more and more bash scripting I thought […]

List AD Organizational Units with Powershell

Here’s a quick Powershell one-liner to list all the Organizational Units, or OUs, in your Active Directory domain. Firstly you’ll probably need to load the ActiveDirectory module. This can be done at the Powershell prompt with the below command; ?View Code POWERSHELLImport-Module ActiveDirectory; Then we can use the Get-ADOrganizationalUnit cmdlet to retrieve a list of […]

Beware the Powershell -Contains operator

Many of us tend to jump quickly, into a new programming or scripting language, applying knowledge we’ve learned elsewhere to the current task at hand. Broadly speaking this works well but these always a little gotcha to trip you up! A good example is the Powershell -contains operator. It’s not like .Net String.Contains method as […]

Monitoring SSRS Subscriptions with Powershell

We don’t use SSRS much at my workplace but its usage is slowly creeping up. I realised that none of us are keeping an eye on the few subscriptions we have set-up. So I decided to do something about that. Here’s a bit of Powershell code that uses the SSRS Web Service to pull out […]

Using Powershell to increment the computers date

Here’s a little snippet of Powershell code I used recently to test some TSQL that runs according to a two week schedule. This code will increment the date by one day, up to the maximum specified in $days, sleeping in between for a short while. The date is set back correctly at the end. Far […]