RSS

Category Archives: Powershell

F7 is very awesome when using PS

you can use F7 to list your executed PS command in GUI view.

image

And this function support auto-match when you type letter.

 
Leave a comment

Posted by on February 17, 2011 in Powershell

 

restrict user access ECP

In Exchange 2010, you may need to restrict user access ECP to avoid employee information incompliance issue. So you have to use RBAC make it real.
The useful role is Mybaseoptions. you can see what it can done in help.
Run below PS in EMC use a organization administrator privilege account.
 
Set-RoleAssignmentPolicy "Default Role Assignment Policy" -Name "Unrestricted Role Assignment Policy"
 
New-RoleAssignmentPolicy -Name "Restricted Role Assignment Policy" -Description "This policy does not allow end users to set their OWA Options and 
perform other self-administration tasks." -Roles MyBaseOptions -IsDefault:$True
 
get-mailbox | ? {$_.department –eq “HR”}| set-mailbox -RoleAssignmentPolicy "Restricted Role Assignment Policy"
 
 
 

download SCOM r2 VHD using PS way from MS

thanks for stefan stranger’s share.

quote:

Save script to DownloadVHD.ps1 and run from PowerShell.

###############################################################################
# Download VHD Test Drive – System Center Operations Manager 2007 R2 from
# http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ef67ea4f-b8af-436f-80ae-33936f26f110
# in one-go using PowerShell and Bits.
# Remark: Use PowerShell 2.0 because it makes use of the BitsTransfer Module
# Author: Stefan Stranger
# v1.001 – 14/02/2011 – stefstr – initial release
###############################################################################

$global:path = "c:\Temp\"

Import-Module BitsTransfer #Loads the BitsTransfer Module
Write-Host "BitsTransfer Module is loaded"

$OpsMgrVHDs = @("http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/EULA.txt",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/README.rtf",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part01.exe",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part02.rar",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part03.rar",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part04.rar",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part05.rar",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part06.rar",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part07.rar",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part08.rar",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part09.rar",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part10.rar",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part11.rar",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part12.rar",
"http://download.microsoft.com/download/4/A/F/4AFA721B-842E-4253-82E7-A53E09FC191E/VHD_OpsMgr2007R2.part13.rar")

Foreach ($OpsMgrVHD in $OpsMgrVHDs) { Start-BitsTransfer $OpsMgrVHD $path}
Write-Host "OpsMgr VHD’s are downloaded to $path"

 
 

get mac address

gwmi –class win32_networdadapter

get mac

ipconfig /all

the best way is gwmi, am i right?

 
Leave a comment

Posted by on October 1, 2010 in Powershell

 

Tags: , ,

build your own table more efficaciously

$column1 = @{expression="Name"; width=30; label="filename"; alignment="left"}

$column2 = @{expression="LastWriteTime"; width=40;label="last modification"; alignment="right"}

Dir | Format-Table $column1, $column2

$column1 = @{expression="Name"; width=25; label="filename"; alignment="left"}

$column2 = @{expression="id"; width=8;label="PID"; alignment="right"}

gps | Format-Table $column1, $column2

 
Leave a comment

Posted by on September 26, 2010 in Powershell

 

out-gridview

this ps view method is very nice for data analyze,  include filter as well.

 
Leave a comment

Posted by on August 29, 2010 in Powershell

 

$([char]num)

11..14 | foreach {"$_ $([char]$_)" }
$([char]11)
$([char]65)
$([char]97)
65..70 | foreach {"$_ $([char]$_)" }
97..100 | foreach {"$_ $([char]$_)" }

cool

 
Leave a comment

Posted by on June 7, 2010 in Powershell

 
 
%d bloggers like this: