From ece7a801a6b43401974bddbc13a012f4b824ebbf Mon Sep 17 00:00:00 2001 From: Brian Farnhill Date: Fri, 2 Oct 2015 10:23:22 +1000 Subject: [PATCH] Added formatting test to username parameters --- .../Modules/xSharePoint.Util/xSharePoint.Util.psm1 | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 index 3bcd9be0b..7b5b5c388 100644 --- a/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 +++ b/Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1 @@ -5,6 +5,10 @@ function Add-xSharePointUserToLocalAdmin() { [parameter(Mandatory = $true,Position=1)] [string] $UserName ) + if ($UserName.Contains("\") -eq $false) { + throw [Exception] "Usernames should be formatted as domain\username" + } + $domainName = $UserName.Split('\')[0] $accountName = $UserName.Split('\')[1] @@ -102,6 +106,10 @@ function Remove-xSharePointUserToLocalAdmin() { [parameter(Mandatory = $true,Position=1)] [string] $UserName ) + if ($UserName.Contains("\") -eq $false) { + throw [Exception] "Usernames should be formatted as domain\username" + } + $domainName = $UserName.Split('\')[0] $accountName = $UserName.Split('\')[1] @@ -162,6 +170,10 @@ function Test-xSharePointUserIsLocalAdmin() { [parameter(Mandatory = $true,Position=1)] [string] $UserName ) + if ($UserName.Contains("\") -eq $false) { + throw [Exception] "Usernames should be formatted as domain\username" + } + $domainName = $UserName.Split('\')[0] $accountName = $UserName.Split('\')[1]