Tag Cloud


Anything and everything POSH!

Powershell: Install Exchange

Another exchange related function (who could guess!) I recently finished is this one. It will download the exchange setup file and install the role you require to be installed. You have to provide the role you want to install, the exchange version and the organization name. Works for 2010 and 2013. Might update this in the future to include RU installations.

Powershell: Prepare for an Exchange installation

I’m not taking full credit for this one. This script was originally made by someone else (and as soon as I find the link to that post I’ll put it up!) to prepare for Exchange 2010 on windows 2008 and 2008 R2.

I’ve updated it for server 2012 and Exchange 2013, converted it to a function and make you choose th

Powershell Script: Deploying Virtual Machines

I’m a lazy bastard and am constantly looking for ways to deploy my lab machines faster and with less effort. I’m interested in learning and testing as much as I can but I just don’t want to be installing machines constantly! The first step for me was experimenting with MDT, which was brilliant! But it still took to long to install a VM and still too much effort (told you I’m lazy : ))! So the second step for me was to create a number of VHDX files and use those to deploy the virtual machines resulting ......

Powershell: If statements dependent on installed exchange role

Something I need to keep for usage in the future:$hostname=hostnameIf (get-exchangeserver $hostname | where {$_.isClientAccessServer -eq $true}) { } else { } If (get-exchangeserver $hostname | where {$_.isHubTransportServer -eq $true}) { } else { }If (get-exchangeserver $hostname | where {$_.isMailboxServer -eq $true}) { } else { }If (get-exchangeserver $hostname | where {$_.isUnifiedMessagingServer -eq $true}) { } else { }If (get-exchangeserver $hostname | where {$_.isEdgeServer -eq $true}) { } ......

Powershell: Connect to Exchange server powershell

Connecting to Exchange powershell is, for normal operations, as simple as opening the shortcut on you start menu :).However, if you have the need to have some scripts perform actions against your Exchange you can use the below code to make that happen!$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://YourCASServerFQDN/Po... -Authentication Kerberos Import-PSSession $s Add-PSSnapin Microsoft.Exchange.Manageme... . $env:ExchangeInstallPath\bi... ......

Powershell: Install-dotNET4 function

This function will download and install ,NET 4.0. It uses the Get-Framework-Versions function to determine if the installation is necessary or not. Internet Connectivity will be required as the script auto downloads the setup file (and sleeps for 360 seconds... I had a function in there to monitor for install completion at first, turns out the setup file spawns so many childprocesses the function just got confused and locked up -_-)Alternatively you could drop the installation file in the folder ......

Powershell: Get-Framework-Versions.

This function will use the test-key function posted earlier. It will check which .NET frameworks are installed (currently only checking for .NET 4.0) but can be easily adapted and/or expanded. function Get-Framework-Versions(){ $installedFrameworks = @() if(Test-Key "HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Client" "Install") { $installedFrameworks += "4.0c" } if(Test-Key "HKLM:\Software\Microsoft\NET Framework Setup\NDP\v4\Full" "Install") { $installedFrameworks += "4.0" } return $installedFrameworks} ......

Powershell Test Reg Key function

Disclaimer: Code is not mine but forgot where I got it. Ping me if this is yours and you will receive full kudos to it :)

function Test-Key([string]$path, [string]$key)
    if(!(Test-Path $path)) { return $false }
    if ((Get-ItemProperty $path).$key -eq $null) { return $false }
    return $true

Powershell Run-As Script

Disclaimer: This script is not of my own making. I found it on a share somewhere and it is so handy I started using in a bunch of scripts. To the writer: If you're out there, somewhere, when you see this, thank you! Check if script is running as Adminstrator and if not use RunAs # Use Check Switch to check if admin param([Switch]$Check) $IsAdmin = ([Security.Principal.Window... [Security.Principal.Windows... ).IsInRole([Security.Princi... "Administrator") ......