From 7a2a6faa1f34c80dd780b70915db577ba37e10b9 Mon Sep 17 00:00:00 2001 From: Bob White Date: Fri, 2 Mar 2018 14:08:47 -0800 Subject: [PATCH] added admin stipulation to on prem set up --- Resources/ActionScripts/SetupVM.ps1 | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Resources/ActionScripts/SetupVM.ps1 b/Resources/ActionScripts/SetupVM.ps1 index 113296d..e4b90a5 100644 --- a/Resources/ActionScripts/SetupVM.ps1 +++ b/Resources/ActionScripts/SetupVM.ps1 @@ -6,11 +6,11 @@ param( [ValidateNotNullOrEmpty()] [string]$serverName, -[parameter(Mandatory=$True, Position=2)] +[parameter(Mandatory=$false, Position=2)] [ValidateNotNullOrEmpty()] [string]$username, -[parameter(Mandatory=$True, Position=3)] +[parameter(Mandatory=$false, Position=3)] [ValidateNotNullOrEmpty()] [string]$password, @@ -20,6 +20,14 @@ param( ) +###Check to see if user is Admin + +$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` + [Security.Principal.WindowsBuiltInRole] "Administrator") + +if ($isAdmin -eq 'True') { + + ################################################################# ##DSVM Does not have SQLServer Powershell Module Install or Update ################################################################# @@ -280,9 +288,23 @@ Stop-Transcript ##Launch HelpURL Start-Process "https://microsoft.github.io/$SolutionFullName/Typical.html" +##Launch HelpURL +Start-Process "https://microsoft.github.io/$SolutionFullName/Typical.html" + ## Close Powershell if not run on + ## if ($baseurl) + Exit-PSHostProcess + EXIT +} + +ELSE +{ + + Write-Host "To install this Solution you need to run Powershell as an Administrator. This program will close automatically in 20 seconds" + Start-Sleep -s 20 + ## Close Powershell Exit-PSHostProcess -EXIT \ No newline at end of file +EXIT } \ No newline at end of file