Posts Tagged ‘Powershell’

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 […]

Testing a Failover Cluster with Powershell

Just a quick Powershell snippet that I’m going to use to run validation tests on one of my staging Failover Clusters during OOH. The script below will take some services offline, run the validation tests, before bringing the appropriate cluster groups back online. The report will be saved using the date as the name. To […]

Domain user password expiry with Powershell

I needed to figure out a method for producing alerts when a domain account is approaching the password reset date. Here it is in a few lines of Powershell… ?View Code POWERSHELL# Set name here $name = "Rhys Campbell"; $user = Get-ADUser -LDAPFilter "(Name=$name)" -Properties PasswordLastSet; $days = $(Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge; $expires = $user.PasswordLastSet + $days; $days_left […]

Checking Disk alignment with Powershell

Disk alignment has been well discussed on the web and the methods to check this always seem to use wmic or DISKPART. I’ve always loathed wmi so here’s a few lines of Powershell that achieves the same thing; ?View Code POWERSHELL$sqlserver = "sqlinstance"; # Get disk partitions $partitions = Get-WmiObject -ComputerName $sqlserver -Class Win32_DiskPartition; $partitions […]