PowerShell: Run IISReset on All Servers in your farm at the same time

image

 

IIS-Reset.ps1

One of the many things scripts are good for in general  is making repetitive tasks easier and the results more consistent. PowerShell takes it to another level with its intuitive cmdlets . I find it much easier run a script from my laptop or log into a single server rather than using MSTSC to login to every server in the farm, I am working in a SharePoint environment of 25 servers, so it wouldn’t definitely be a drag..

 

 

 

PowerShell Script

<#    IIS-Reset.ps1
Run IISReset on Multiple Servers #>

#Specify servers in an array variable
[array]$servers = "Server1","Server2","Server3","Server4"

#Step through each server in the array and perform an IISRESET
foreach ($server in $servers)
{
    Write-Host "Restarting IIS on server $server..."
    IISRESET $server /noforce
    Write-Host "IIS status for server $server"
    IISRESET $server /status
}
Write-Host IIS has been restarted on all servers

Download http://1drv.ms/1ZjF889

 

Ivan

del.icio.us Tags: PowerShell,IISReset,SharePoint

PowerShell: Backup your running Hyper-V Virtual Machines

If your like every one else including me its been a complete drag attempting to get clients to allow you to shut down Virtual Machines that are in production to allow you to back them up.  Windows Server 2012 R2 (a free upgrade of Windows Server 2012) can be upgraded remotely using RDP without too much risk. I competed 4 Hyper-V Hosts Friday night without issue. The upgraded is pretty fast but we had to migrate the running VMs prior to the upgrade, and it too about an hour to bring the  the new 2012 R2 Hyper-V hosts current with all Security and Hot Fixes (132 patches) .

image

 

Set-VMBackup.ps1

We have the backups  using task scheduler, since we have multiple Hyper-V hosts, we created the schedule once then exported to xml, and imported the task on all additional Hyper-V Hosts.

 

 

Also, since the VMs rarely change we keep two backups locally and the rest are moved to the SAN in this case a NetApp for two weeks and copied to tape. Note: You only need to modify the drive and root folder, if the folder does not exist it will be created.

PowerShell Script

<# Set-VMBackup.ps1 #>

#Get date string
$timestamp = Get-Date -UFormat "%Y%m%d"

#Change the Drive / Folder where the exports should be stored
$BackupPath = “D:\VMBackup\$timestamp#Export running VMs to Export path
GET-VM | where {$_.state -eq ‘running’} | Export-VM -Path $BackupPath

Download http://1drv.ms/1PPFoUg

 

Ivan

PowerShell: Upgrade WAC – your Office Web Apps Farm

Like most folks who upgrade their SharePoint 2013 farms after they have applied the latest SharePoint 2013 CUs to the SharePoint side of the environment they will usually still have 2 WAC servers and at least 3 WFM servers left to apply and configure updates. This may depend on release of the updates as the Service Bus and Workflow manager updates do not coincide with the monthly delivery of SharePoint 2013 CUs.

image

 

Upgrade-WAC.ps1

The reason for this post is to make it easy for me (not to forget) updating the WAC Servers / Office Web App Farm. Updating the Office Web App farm is somewhat unique in that you remove the farm prior to the installing the CU then create a new farm after the cumulative update installed


 

 

 

 

PowerShell Script

# Update-WAC.ps1
# Add July 2015 CU

Import-Module -Name OfficeWebApps 

# Review the Current State of the Office Web App Environment
Get-OfficeWebAppsFarm 
Get-OfficeWebAppsHost 
Get-OfficeWebAppsMachine 
cmd /c pause 

# Remove OfficeWebAppMachine prior to installing Cumulative Update
Remove-OfficeWebAppsMachine
cmd /c pause

# Install the Cummulative Update while paused

# Configure Office WebApp Farm after installing the updates
# If using HTTP remove comment below
# New-OfficeWebAppsFarm -InternalURL "http://wac.contoso.com" -AllowHTTP -EditingEnabled

New-OfficeWebAppsFarm -InternalURL "https://wac.contoso.com" -ExternalURL "https://wac.contoso.com" -CertificateName "wac.contoso.com" -EditingEnabled
cmd /c pause

# Open IE to test and ensure the New OfficeWebApps Farm is configured
$ie = New-Object -ComObject InternetExplorer.Application
$ie.Navigate("https://wac.contoso.com/hosting/discovery.ashx")
$ie.Visible = $true
If successful your browser will open and will look the example below

SNAGHTML39a1ce2e

 

Download http://1drv.ms/1JCmcKm

 

Ivan

Force directory synchronization using Windows PowerShell

The reason I use this blog at times is to remember the issue I tend to for get and this s one of those commands

You can use the directory synchronization Windows PowerShell cmdlet to force synchronization. The cmdlet is installed when you install the Directory Synchronization tool.

On the computer that is running the Directory Synchronization tool, navigate to the directory synchronization installation folder. By default, it is located here: %programfiles%\Microsoft Online Directory Sync.
so just add the path to your environment variables and you can run DirSyncConfigShell.ps1 to open a Windows PowerShell window with the cmdlets loaded.

Then, type Start-OnlineCoexistenceSync, and then press ENTER.

 

-Ivan