Check Hyper-V replication status using Powershell

One of my colleges sent me this little snippet today for easily checking replication status on the VMs on our hyper-v host… I modified it for checking multiple hosts:

Get-VMReplication -computername HOST1,HOST2,HOST3 | select-object lastreplicationtime, vmname, computername | Sort-Object -Property LastReplicationTime | ft -AutoSize


How to monitor Windows 2008 R2 Servers from Server Manager in Windows Server 2012

This will be a very short and sweet description on how to monitor Windows Server 2008 R2 from Windows Server 2012

  1. Start by installing .NET 4 Framework on the 2008 R2 Server
  2. Install Windows Management Framework 3.0 in the 2008 R2 server
  3. Run winrm qc in an elevated command prompt on the Windows Server 2008 R2 computer
  4. To be able to use BPA on the 2008 R2 server run Enable-PSremoting –Force from an elevated PowerShell prompt
  5. Done…

Force update of Exchange 2010 address lists

If you add a new mailbox or a distribution list to your Exchange 2010 server you need to either wait for the address lists to update you can force them to update.

In the Exchange management prompt run:

Get-GlobalAddressList | update-GlobalAddressList
Get-AddressList | update-AddressList
Get-OfflineAddressBook | Update-OfflineAddressBook

On the Clients you might need to update the Offline Address Book by going to Send/Receive – Send/Receive Groups – Download Address Book…


Adding and removing the GUI in Windows Server 2012

In Windows Server 2008 R2 you could select whether you wanted to run Standard (GUI) och Core version of Windows Server. In Windows Server 2012 the GUI is a feature which you can add or remove.

To remove the GUI you use the following Powershell one-liner:

Remove-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

You can also uninstall the GUI, which removes the binary files from the disk. To completely uninstall the GUI you use the following Powershell one-liner:

Uninstall-WindowsFeature Server-Gui-Shell, Server-Gui-Mgmt-Infra

If you realize you are in over your head you can add it back in using:

Add-WindowsFeature Server-Gui-Shell

… or:

Install-WindowsFeature Server-Gui-Mgmt-Infra,Server-Gui-Shell –Restart –Source c:\mountdir\windows\winsxs

You can also do all of this using Dism:
Dism /online /enable-feature /featurename:ServerCore-FullServer /featurename:Server-Gui-Shell /featurename:Server-Gui-Mgmt


TrueSec on The Scripting Guys

As you might know Microsoft has a site called The Scripting Guys. My colleague Niclas Goude will be writing a couple of guest blogs on The Scripting Guys regarding security from the 2:nd to the 6:th of July.

The specific subjects will be:

Monday: Scanning
Tuesday: Brute Force
Wednesday: Shares and Metadata
Thursday: Give yourself System Permission without psexec
Friday: LSA Secrets

Sessions, Sessions, Sessions…

I did not have the possibility to visit eighter MMS or TechED North America this year but fortunately Microsoft makes all the sessions available for download. The problem is that it takes a lot of time to download the ones I want. So I tried to find a better way to do it and someone has written a script Smile

In the links below you will find the two scripts.


Hosted Exchange 2010 SP1

Håller just nu på att installera en Hosted Exchange 2010 lösning hos en kund och tänkte att jag skulle samla lite resurser och skriva ner lite instruktioner:

Powershell Snippets

Skapa en organisation

   1: Password = Read-Host "Enter Password" -AsSecureString

   2: New-organization -name TestOrg -DomainName -ProgramId HostingSample -OfferId 2 -location sv-SE -AdministratorPassword $Password

Radera alla mailboxar i en organisation

   1: get-mailbox -Organization TestOrg | remove-mailbox

Radera Organisation

   1: Remove-Organization TestOrg

Skapa användare i Organisation

   1: $OrgName = TestORG

   2: Import-CSV CreateRecipients.csv | foreach {new-mailbox $ -userPrincipalName $_.UPN -org $OrgName -Password (ConvertTo-SecureString $_.password -AsPlainText -Force)}

Vi läser filen CreateRecipients.csv och skapar användare i Organisationen. CreateRecipients.csv skall se ut så här:

   1: Name,UPN,Password

   2: Nisse Hult,,P@ssw0rd1

   3: Kalle Kula,,P@ssw0rd2

Lägg till mailadresser för en användare

   1: $user = Get-Mailbox -identity $args[0] -organization TestOrg

   2: $CLIARGS=$args[1..($args.length - 1)]

   3: ForEach ($CLIARG in $CLIARGS)

   4: {

   5: $user.emailAddresses+=$CLIARG

   6: }

   7: Set-Mailbox $user -emailAddresses $user.emailAddresses

Detta script lägger till extra mailadresser för en användare. Spara scriptet som AddEmail.ps1 och kör det enligt följande:

AddEmail.ps1 [primary email] [extra email 1] [extra email 2]…


Microsoft Exchange Server 2007 – Public Folders

Some powershell stuff on managing Public Folders in Exchange 2007

Create Public Folder

   New-PublicFolder -name "Name"

Remove a Public Folder

   Remove-PublicFolder -Identity "My Public Folder"

Get information on Public Folders

   Get-PublicFolder or Get-PublicFolder -Identity ""

Get information on all public folders

   Get-PublicFolder -Recurse | Format-List Name

get info on all system folders (not otherwise visible)

   Get-PublicFolder -Identity NON_IPM_SUBTREE -Recurse | Format-List Name 

What I need to find out:

– I could not find how to create a Contacts och Calendar Folder
– I could not find out how to change permissions on the root of the Public Folder tree
– I could not change the permission on the public folders