Skip to content

Commit

Permalink
Added formatting test to username parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianFarnhill committed Oct 2, 2015
1 parent 2b417f6 commit ece7a80
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Modules/xSharePoint/Modules/xSharePoint.Util/xSharePoint.Util.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down

0 comments on commit ece7a80

Please sign in to comment.