replace cmd with powershell


If you want to open PowerShell instead of a normal command prompt (cmd.exe) when you enter “cmd” into Run, just open PowerShell as Administrator and enter the below.  It will create a registry key and act much like an alias.

New-Item “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\cmd.exe” Set-ItemProperty -Name “(default)” -Value “C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe”

read-only access to netapp oncommand


Special thanks to Dan’s Tech Notes for info on creating a read-only group in NetApp OnCommand.  This also works on Data ONTAP 8.

useradmin role add oncommand-login -a login-http-admin,api-system-get-*

useradmin role add oncommand-view -a api-aggr-list-info,api-disk-sanown-list-info,api-license-list-info,api-options-get,api-perf-object-get-instances,api-snmp-status,api-volume-list-info*,cli-priv,api-aggr-options-list-info,api-aggr-check-spare-low,api-cf-status

useradmin role add oncommand-volumes-view -a api-volume-get-root-name,api-snapshot-reserve-list-info,api-volume-get-language,api-volume-options-list-info,cli-date

useradmin role add oncommand-sharedfolders-view -a api-cifs-share-list-iter,api-nfs-exportfs-list-rules,api-cifs-session-list-iter

useradmin role add oncommand-qtree-view -a api-qtree-list-iter*

useradmin role add oncommand-disk-view -a api-system-cli,api-disk-list-info,cli-options

useradmin role add oncommand-aggr-view -a api-aggr-get-root-name,api-snapshot-list-info

useradmin group add oncommand-storage-view -r oncommand-login,oncommand-view,oncommand-volumes-view,oncommand-sharedfolders-view,oncommand-qtree-view,oncommand-disk-view,oncommand-aggr-view

use powershell to get an oauth 2 access token


I wrote a little PowerShell script to retrieve an Access Token via OAuth 2.0 that may come in handy for someone else.  This script is specifically for the Google Groups Provisioning API, but can be adapted to other Google API’s, or any other API, by modifying the necessary variables to send a request in the required format. Get the script here:

change time zone for all computers in an ou with powershell


Here’s a little PowerShell script you can use to change the time zone for all computers in a certain OU.

Start-Transcript Import-Module ActiveDirectory $cred = Get-Credential

$arr = Get-ADComputer -SearchBase ‘OU=Servers,OU=example,dc=blah,dc=com’ -Filter ’*’ Select-Object -ExpandProperty Name

#for debugging - manually set the array for testing #$arr = “server01”, “server02”

foreach ($a in $arr) { Write $a Write “current time zone is” invoke-command -cn $a -cred $cred {tzutil /g} Write “————–” Write “overwriting time zone” invoke-command -cn $a -cred $cred {tzutil /s “Central Standard Time”} Write “————–” }


add users to a group based on an ad attribute


Props to TechNet forums user philldogger for this one.  If you want to build a group in AD based on the value of an attribute that the users will have (e.g. make a DFS group based on Department) you can do this:

Import-Module ActiveDirectory Get-ADUser -filter{department -like “Accounting”} | %{Add-ADGroupMember dfs_dept_Accounting $_.SamAccountName}

In this example I am specifying the “department” AD attribute and looking for anyone who’s Department is set to “Accounting” and adding them to my AD group named “dfs_dept_Accounting”.   If you want to script it so the group membership is updated as new people join, add this line below the importing of the AD PowerShell module.

Get-ADGroupMember dfs_dept_Accounting %{remove-adgroupmember dfs_dept_Accounting $_.SamAccountName -Confirm:$false}

This will wipe out the group and then re-add everyone.  You can have one script per group you’d like to be updated, or combine multiple into one script.  Fair warning though, if you have a good sized AD the script’s could take a long time to run and may hammer your DC’s so do due diligence.