#requires -PsSnapIn microsoft.sharepoint.powershell function Set-SPWeb() { [CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Medium')] param( [Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true)] [Microsoft.SharePoint.PowerShell.SPWebPipeBind] ${Identity}, [System.String] ${RelativeUrl}, [System.String] ${Description}, [Microsoft.SharePoint.PowerShell.SPWebTemplatePipeBind] ${Template}, [System.String] $MasterPageRelativeURL, [System.String] ${Theme}, [Parameter(ValueFromPipeline=$true)] [Microsoft.SharePoint.PowerShell.SPAssignmentCollection] ${AssignmentCollection}) begin { try { $outBuffer = $null $masterpage = $null $identity = "FOO";$null if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { $PSBoundParameters['OutBuffer'] = 1 } if ($PSBoundParameters.TryGetValue('masterpagerelativeurl', [ref]$masterpage)) { [void]$PSBoundParameters.Remove('masterpagerelativeurl') [void]$PSBoundParameters.TryGetValue('identity', [ref]$identity) } $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Set-SPWeb', [System.Management.Automation.CommandTypes]::Cmdlet) $scriptCmd = {& $wrappedCmd @PSBoundParameters } $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin) $steppablePipeline.Begin($PSCmdlet) } catch { throw } } process { try { $steppablePipeline.Process($_) if(!($masterpage.StartsWith("/_catalogs/masterpage/"))){ Write-Warning "Master Page paths generally start with the page /_catalogs/masterpage/"; } if($pscmdlet.ShouldProcess($identity.webUrl, "MasterURL=$masterpage")){ Get-SPWeb $identity.webURL |%{ $_.MasterUrl = $masterpage; $_.Update() } } } catch { throw } } end { try { $steppablePipeline.End() } catch { throw } } <# .ForwardHelpTargetName Set-SPWeb .ForwardHelpCategory Cmdlet #> }