Showing posts with label powershell. Show all posts
Showing posts with label powershell. Show all posts

Tuesday, March 4, 2014

Enabling Remote Volume Management with PowerShell

I run a build server that's fully virtualized using Microsoft Hyper-V Server 2012 Standalone, and I'm in the process of upgrading to Hyper-V 2012 R2.

One step I've always had to do is to enable Remote Volume Management. I could probably do this in AD, but old habits die hard.

I went into "netsh advfirewall" on the new server and it gave me a message:

In future versions of Windows, Microsoft might remove the Netsh functionality
for Windows Firewall with Advanced Security.

Microsoft recommends that you transition to Windows PowerShell if you currently
use netsh to configure and manage Windows Firewall with Advanced Security.

Type Get-Command -Module NetSecurity at the Windows PowerShell prompt to view
a list of commands to manage Windows Firewall with Advanced Security.

Visit http://go.microsoft.com/fwlink/?LinkId=217627 for additional information
about PowerShell commands for Windows Firewall with Advanced Security.

Certainly, there must be a way to do this with PowerShell.

My translation of the trusty:
netsh firewall advfirewall set rule group="Remote Volume Management" new enable=yes

Is the following:

Get-NetFirewallRule -DisplayGroup "Remote Volume Management" | Set-NetFirewallRule -Enabled True


Wednesday, November 6, 2013

PowerShell script for finding iOS 6.1 devices using ActiveSync your Exchange server

NOTE: I originally wrote but never finished this entry back in February, when iOS 6.1 came out.

iOS 6.1, released earlier this month (in February) (and also 6.1.1), had a fairly severe bug in how it interacts with Exchange 2010 SP1 and later.This is documented by both Apple and Microsoft.This caused Exchange logs to grow very quickly, as well as additional CPU load and memory use.

My Exchange deployment is fairly small, 75 users.Even still, I took a look and was surprised just how fast our logs were growing. About 1/2 GB per hour with only 10-15 devices on iOS 6.1, and I'm not even sure all of them were causing the problem.

I decided to take this opportunity to see if I could use PowerShell to find a list of users with iOS devices running version 6.1. A quick search, and some simple filtering, and here's a one-liner that can be run from the Exchange Management Shell (EMS) in Exchange 2010. Note this cmdlet will not work in Exchange 2007.

Get-ActiveSyncDevice | Where-Object -FilterScript {$_.DeviceUserAgent -like "Apple*" -and $_.DeviceOS -like
"iOS 6.1 *"} | Sort-Object UserDisplayName | Format-Table DeviceType,DeviceOS,FriendlyName,UserDisplayName -AutoSize



I chose to sort by UserDisplayName, the best user-identifying field I could find on an Object returned by Get-ActiveSyncDevice, since some users have an iPad and iPhone. I'm sure someone with better PowerShell-fu could pipe this to something that would spit out a list of email addresses, or maybe even send out an email to upgrade.

This allowed me to inform only those users causing the problem, rather than the whole company. It also enabled me to easily verify once everyone had updated.

PowerShell rocks. Haven't used it? I strongly suggest checking out the following on Microsoft Virtual Academy:
- Getting Started With PowerShell 3.0 Jump Start
- Advanced Tools Scripting with PowerShell 3.0 Jump Start

The first series starts off a little slow for experienced command shell users, but these videos are well worth your time (as is learning PowerShell).