Categories
Microsoft

Windows 2012 R2 : Configure a Network Adapter Using PowerShell

In my quest to automate Windows 2012 R2 deployment (along with SQL 2014 and SharePoint 2013) I wanted to simplify the static IP addressing of my deployed VMs. The following PowerShell commands below will configure the default Network Adapter – always named “Ethernet” in a standard windows 2012 R2 deployment – the script can be easily modified to suit your environment/IP addressing requirements:

$nic = Get-NetAdapter -Name Ethernet
$nic | Set-NetIPInterface -Dhcp Disabled
$nic | New-NetIPAddress -IPAddress 192.168.0.201 -PrefixLength 24 –DefaultGateway 192.168.0.1
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses "192.168.0.1"
Categories
Microsoft

Windows 2012 R2 : Script to Rename Computer Based Upon Hyper-V Guest Name

I came across the following TechNet post recently which is useful for deploying Hyper-V machines and automating machine renaming to be in-line with the names given to you Hyper-V guests:https://gallery.technet.microsoft.com/scriptcenter/Automate-Virtual-Machine-6c17929c

However, I ran into issues when testing on a Windows 2012 R2 Hyper-V Server and Windows 2012 R2 guest, so modified the rename component as follows – ensure you run from within the guest Operating System:

$virtualmachinename= (Get-ItemProperty 'HKLM:\software\microsoft\virtual machine\guest\parameters').virtualmachinename 
Rename-Computer -NewName $virtualmachinename.ToUpper()
Restart-Computer
Categories
Microsoft

Windows 2012 R2 : Forgot to Install the GUI?

In automating the deployment of some Windows 2012 R2 servers on a lab I neglected to select the ‘with GUI’ option during Windows Setup, use the script below to restore the GUI:

Powershell
Install-WindowsFeature Server-Gui-Mgmt-Infra, Server-Gui-Shell -Source:wim:D:\sources\install.wim:2
Restart-Computer
Categories
Microsoft

SharePoint 2013 : Script to Download Pre-Requisites for Offline Install

In automating a SharePoint 2013 SP1 deployment on Windows Server 2012 R2 I came across the following PowerShell script to facilitate offline deployment of all Shareoint 2013 SP1 pre-requisites: https://gallery.technet.microsoft.com/office/DownloadInstall-SharePoint-e6df9eb8

The only issue with this script is that it is for Windows 2012 / SharePoint 2013 RTM only.

The modified copy below facilitates all Windows 2012 R2 / SharePoint 2013 SP1 pre-requisite downloads – including naming of the downloads as required by the pre-requisite installer.

{code lang:text showtitle:false lines:false hidden:false}#***************************************************************************************
# Written by Craig Lussier - http://craiglussier.com
#
# Udated for Windows 2012 R2/SharePoint 2013 SP1 by Chris Bradford - 
#
# This script downloads SharePoint 2013 Prerequisites
#
# -Only run this script on Windows Server 2012 (RTM, either Standard or Datacenter)
# -Do not run this script on a Windows Server 2008 R2 SP1 Server!
# ---These are the Prerequisites for Windows Server 2012
# -Run this script as a local server Administrator
# -Run PowerShell as Administrator
#
# Don't forget to: Set-ExecutionPolicy RemoteSigned
# If you have not done so already within you Windows Server 2012 server
#****************************************************************************************
param([string] $SharePoint2013Path = $(Read-Host -Prompt "Please enter the directory path to where you wish to save the SharePoint 2013 Prerequisite files."))

# Import Required Modules
Import-Module BitsTransfer

# Specify download url's for SharePoint 2013 prerequisites
$DownloadUrls = (
         "http://download.microsoft.com/download/9/1/3/9138773A-505D-43E2-AC08-9A77E1E0490B/1033/x64/sqlncli.msi", # Microsoft SQL Server 2008 R2 SP1 Native Client
         "http://download.microsoft.com/download/E/0/0/E0060D8F-2354-4871-9596-DC78538799CC/Synchronization.msi", # Microsoft Sync Framework Runtime v1.0 SP1 (x64)
         "http://download.microsoft.com/download/A/6/7/A678AB47-496B-4907-B3D4-0A2D280A13C0/WindowsServerAppFabricSetup_x64.exe", # Windows Server App Fabric
         "http://download.microsoft.com/download/7/B/5/7B51D8D1-20FD-4BF0-87C7-4714F5A1C313/AppFabric1.1-RTM-KB2671763-x64-ENU.exe", # CU 1 for AppFabric 1.1 (KB2671763)
         "http://download.microsoft.com/download/7/B/5/7B51D8D1-20FD-4BF0-87C7-4714F5A1C313/AppFabric1.1-RTM-KB2671763-x64-ENU.exe", # Cumulative Update Package 1 for Microsoft AppFabric 1.1 for Windows Server (KB2671763)
         "http://download.microsoft.com/download/D/7/2/D72FD747-69B6-40B7-875B-C2B40A6B2BDD/Windows6.1-KB974405-x64.msu", #Windows Identity Foundation (KB974405)
         "http://download.microsoft.com/download/0/1/D/01D06854-CA0C-46F1-ADBA-EBF86010DCC6/rtm/MicrosoftIdentityExtensions-64.msi", # Microsoft Identity Extensions
         "http://download.microsoft.com/download/9/1/D/91DA8796-BE1D-46AF-8489-663AB7811517/setup_msipc_x64.msi", # Microsoft Information Protection and Control Client
         "http://download.microsoft.com/download/8/F/9/8F93DBBD-896B-4760-AC81-646F61363A6D/WcfDataServices.exe", # Microsoft WCF Data Services 5.0
         "http://download.microsoft.com/download/1/C/A/1CAA41C7-88B9-42D6-9E11-3C655656DAB1/WcfDataServices.exe" # Microsoft WCF Data Services 5.6 (rename this download to WcfDataServices56.exe)
	)

function DownLoadPreRequisites() {
	Write-Host ""
	Write-Host "====================================================================="
	Write-Host " Downloading SharePoint 2013 Prerequisites Please wait..."
	Write-Host "====================================================================="
	$ReturnCode = 0

	foreach ($DownLoadUrl in $DownloadUrls) {
		## Get the file name based on the portion of the URL after the last slash
		If ($DownloadUrl -eq "http://download.microsoft.com/download/1/C/A/1CAA41C7-88B9-42D6-9E11-3C655656DAB1/WcfDataServices.exe") {$filename = "WcfDataServices56.exe"}
    Else {$FileName = $DownLoadUrl.Split('/')[-1]}

	Try {
		## Check if destination file already exists
		If (!(Test-Path "$SharePoint2013Path\$FileName")){
			## Begin download
			Start-BitsTransfer -Source $DownLoadUrl -Destination $SharePoint2013Path\$fileName -DisplayName "Downloading `'$FileName`' to $SharePoint2013Path" -Priority High -Description "From $DownLoadUrl..." -ErrorVariable err
		If ($err) {Throw ""}}
		Else {
			Write-Host " - File $FileName already exists, skipping..."
			}
		}
		Catch {
			$ReturnCode = -1
			Write-Warning " - An error occurred downloading `'$FileName`'"
			Write-Error $_
			break
			}
		}
	Write-Host " - Done downloading Prerequisites required for SharePoint 2013"
	return $ReturnCode
	}

function CheckProvidedDownloadPath() {
	$ReturnCode = 0
	Try {
		# Check if destination path exists
		If (Test-Path $SharePoint2013Path) {
			# Remove trailing slash if it is present
			$script:SharePoint2013Path = $SharePoint2013Path.TrimEnd('\')
			$ReturnCode = 0
		}
	Else {
		$ReturnCode = -1
		Write-Host ""
		Write-Warning "Your specified download path does not exist. Please verify your download path then run this script again."
		Write-Host ""
		}
	}
	Catch {
		$ReturnCode = -1
		Write-Warning "An error has occurred when checking your specified download path"
		Write-Error $_
		break
		}
	return $ReturnCode
	}

function DownloadPreReqs() {
	$rc = 0
	$rc = CheckProvidedDownloadPath
	# Download Pre-Reqs
	if($rc -ne -1) {
		$rc = DownLoadPreRequisites
		}
	if($rc -ne -1) {
		Write-Host ""
		Write-Host "Script execution is now complete!"
		Write-Host ""
		}
	}

DownloadPreReqs
Categories
Microsoft

SharePoint 2013 : Disable SSL on Central Administration

I’ve been testing the AutoSPinstaller recently and ran into an issue where I’d set the “Use SSL” flag on the Central Admin configuration, but had no certificate/didn’t actually want it to use SSL.

I figured I’d just run Set-SPCentralAdministration -Port <PortNumber> to resolve this issue – however this doesn’t change any of the AAMs, notably the default AAM for Central Admin.

Using the PowerShell script I found in the following blog post, the issue was resolved: http://tom-dw.blogspot.co.uk/2010/06/removing-ssl-from-sharepoint-central.html

Be sure to change the URL and port number to suit your requirements.

#Load the SharePoint assembly
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

#Get the central admin webapp
$cAdmApp = [Microsoft.SharePoint.Administration.SPAdministrationWebApplication]::Local

#Create a new alternate url
$altUrl = New-Object "Microsoft.SharePoint.Administration.SPAlternateUrl" -ArgumentList "http://sp2013:8010", "Default"

#Set this alternate url as response url
$cAdmApp.AlternateUrls.SetResponseUrl( $altUrl )
$cAdmApp.AlternateUrls.Update()

#Get the alternate urls definition, this should only list our //http://server:10000 url
$cAdmApp.AlternateUrls
Categories
ConfigMgr

ConfigMgr : Windows 7 x64 OSDComputerName Ignored

We’ve been tetsing a 64-bit build of Windows 7 SP1, that includes IE 10. SCCM 2012 R2 CU1 performs both the Build and Capture Task Sequence alongside all Deployments of the ‘golden image’ to client devices.

The symptoms of this issue were simple, all “Deploy” Task Sequences were failing – on closer inspection it was clear that the machine had not joined the domain, and it had not used the hostname as defined in the OSDComputerName Task Sequence Variable – in fact the machine was using the name of the machine that we used to perform the golden image creation under the Build/Capture Task Sequence!

Having reviewed the sysprep logs on the client there was an error; SYSPRP LaunchDll:Could not load DLL C:\Windows\SysWOW64\iesysprep.dll[gle=0x000000c1]

This was surprising as the Build and Capture Task Sequence was completing successfully, every time.

Categories
Microsoft

SharePoint 2013 : IIS Default Landing Pages / 404 Errors and the Request Management Service

This was an interesting one I came across recently; intermittently we would get reports of users receiving 404 errors and IIS default landing pages, as if SharePoint sites were not running/working on our Web Front End servers.

The SharePoint environment was 2x WFE, 2x Service Application and 1x SQL Server Reporting Services. The WFE servers were load balanced by a HLB. We’re using Host Named Site Collections, so have to manually configure IIS bindings on the Web Front End servers.

There were few errors that really explained what was going on – initially we thought it was a backup related issue, but I think that the backup simply exacerbated the issue rather than caused the issue.

Just prior to raising a support call with Microsoft I came aross the following blog post, which was pretty much like-for-like what we were seeing on our SharePoint 2013 farm:
http://amolmeshe.blogspot.co.uk/2013/05/sharepoint-2013-request-management.html

The issue was pretty simple – the Request Management Service was proxying requests to other servers in the farm – noteably the Service Application and SSRS servers – where IIS is not configured for the HNSCs. On the Service Application servers we had an IIS site listening on all all IPs/host headers, HTTPS – this was for Central Admin. On the SSRS server there was no HTTPS provision – this explained the randome behaviour we were seeing:

  • IIS landing page on the HTTPS-enabled Service Application servers
  • 404 errors on the non-HTTPS enabled SSRS server

Running some simple PowerShell commands we were able to exclude the Service Application and SSRS servers as targets from the Request Management Service configuration – commands taken from the blog above:

$web=Get-SPWebApplication -Identity <URL of web application>

$rm=Get-SPRequestManagementSettings -Identity

$web $m=Get-SPRoutingMachineInfo -RequestManagementSettings $rm -Name <MachineName> Set-SPRoutingMachineInfo -Identity $m -Availability Unavailable

No need to perform an IIS reset, the commands take effect immediately. Alongside resolving the IIS default page/404 errors, we also noticed that the HNSCs loaded significantly faster after making this change.

More info on the Request Management Service here: http://technet.microsoft.com/en-us/library/jj712708.aspx

Categories
Microsoft

SharePoint 2013 : Config Database Large Log File Size

By default the SharePoint 2013 Content Database is set to Full recovery mode – despite reccomendations from MS that this should be set to simple, as outlined here; http://technet.microsoft.com/en-us/library/cc678868(v=office.15).aspx

If unnoticed, you may find your Transaction Log volumes running short on disk space, as we did this morning, follow these steps to relieve storage pressure:

  1. Open SQL Server Management Studio and connect to the SQL Database Instance associated with your SharePoint farm
  2. Find the CONFIG database and right-click | Properties
  3. Under the options tree, change the recovery model to simple and click OK
  4. Again, right-click the CONFIG database | Tasks | Back Up – perform a backup of the CONFIG database
  5. Finally,right-click the CONFIG database | Tasks | Shrink | Files  – select Log under the “File Type” drop-down

It may be worth reviewing your recover models in-line with the URL above, for us it was just the CONFIG database that wasn’t in-line with MS recommendations.

Categories
Microsoft

SharePoint 2013 : Reduce Cumulative Update Installation Time

When upgrading our SharePoint 2013 environment to the June 2014 update we noted installation times in excess of four hours, so when it came to the September update we looked into how we could (if possible) reduce the installaion and deployment time.

I came across the following technet post which reduced installation time significantly on our farms: http://blogs.msdn.com/b/russmax/archive/2013/04/01/why-sharepoint-2013-cumulative-update-takes-5-hours-to-install.aspx