Category Archives: MS Scripting

Hyper-V FreeBSD shutdown problem workaround

Thanks to Mike … 

Mike wrote: 

“I’ve found an even easier way to do this.  I found a PowerShell Hyper-V script at:

http://www.codeplex.com/PSHyperv

It has a lot of functions already, and I added a “Kill-VM” function that automates the kill process:

Kill-VM <VM name>

My modified script is attached to this message.

To use it, you need to install PowerShell (Under Server Manager -> Features in Win2008).  Once installed, run PowerShell from Start -> Search, find the script, and type:

. .hyperv.ps1

Once loaded into memory, type:

Kill-VM <VM Name>

Enjoy”

Click here to download script – hyperv-script.zip

Mailbox statistics using Powershell in Exchange 2007

1. Sorted by Displayname (Display name, Mailbox size (MB), Item count, Last logon time, Last logoff time, Last loggedon user account)

Get-MailboxStatistics -Database “mailbox database” | Sort -Property DisplayName | ft DisplayName,@{expression={$_.totalitemsize.value.ToMB()};label=”Mailbox Size(MB)”}, itemcount, lastlogontime,lastlogofftime,lastloggedonuseraccount

2. Sorted by Last logon time
Get-MailboxStatistics -Database “mailbox database” | Sort -Property lastlogontime | ft DisplayName,@{expression={$_.totalitemsize.value.ToMB()};label=”Mailbox Size(MB)”}, itemcount, lastlogontime, lastlogofftime

Create mail-enabled public folder using Powershell in Exchange 2007

New-PublicFolder -Name “test@test.com” -Path TEST

Enable-MailPublicFolder -Identity “TESTtest@test.com”

Set-MailPublicFolder -Identity “TESTtest@test.com” -EmailAddressPolicyEnabled $false

Set-MailPublicFolder -Identity “TESTtest@test.com” -EmailAddresses “test@test.com”, “test@test.net”, “test@test.org”

Set-MailPublicFolder -Identity “TESTtest@test.com” -PrimarySmtpAddress test@test.comAdd-PublicFolderClientPermission -Identity “TESTtest@test.com” -User Username -AccessRights EditorGet-PublicFolderClientPermission -Identity “TESTtest@test.com” | fl

New certificate in Exchange 2007 step-by-step

1. step
New-ExchangeCertificate -generaterequest:1 -domainname domain.com,mail.domain.com,smtp.domain.com,pop3.domain.com -privatekeyexportable:1 -path c:cert.txt -force:1

2. step
Import certificate request using web access to your Certification authority – logon as administrator! (WEB SERVER!!!)

3. step
Export certificate to a location on the disk… c:certnew.crt

4. step
Import-ExchangeCertificate -path c:certnew.cer

5. step
Enable-ExchangeCertificate -thumbprint 5ACC9A5D90E2CFDBAD6E25CD02362B8954506810 -Services “IIS,POP,SMTP,IMAP”

To remove old certificates:
Remove-ExchangeCertificate -Thumbprint …………