Powershell

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.

Posted On Wednesday, December 18, 2013 12:22 PM | Comments (0)

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

Posted On Wednesday, December 18, 2013 12:13 PM | Comments (0)

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 ......

Posted On Wednesday, February 6, 2013 9:42 AM | Comments (1)

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}) { } ......

Posted On Wednesday, December 5, 2012 12:59 PM | Comments (0)

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... ......

Posted On Wednesday, December 5, 2012 12:35 PM | Comments (0)

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 ......

Posted On Wednesday, December 5, 2012 10:52 AM | Comments (0)

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} ......

Posted On Wednesday, December 5, 2012 8:17 AM | Comments (0)

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
}

Posted On Wednesday, December 5, 2012 8:14 AM | Comments (0)

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") ......

Posted On Wednesday, December 5, 2012 7:59 AM | Comments (0)