Skip to content

Commit

Permalink
added error checking for remove-epo
Browse files Browse the repository at this point in the history
now loops until correct credentials are entered
  • Loading branch information
unknown authored and unknown committed Jan 18, 2014
1 parent a4e7691 commit a6a780a
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions PrepDeploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,30 @@ function remove-ComputerSCCM{
#Many thanks to the people here https://community.mcafee.com/thread/42284
#whose code is a very big influence on the code in this function
function remove-ePo{
#Allows server certificate validation
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

#Asks for ePo credentials and saves as variables
$Credential=Get-Credential -Message "Enter ePO Credentials:"
$epoUser=$Credential.GetNetworkCredential().username
$epoPassword=$Credential.GetNetworkCredential().password

#Creates WebClient to pass commands through
$wc=new-object System.net.WebClient
$wc.Credentials = new-object System.Net.NetworkCredential -ArgumentList ($epoUser, $epoPassword)

#Passes the computer name to the delete command
$wc.DownloadString("$epoServer/remote/system.delete?names=$CompName")
#Allows server certificate validation
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$passed = $false
while ($passed -eq $false) {
#Asks for ePo credentials and saves as variables
$Credential=Get-Credential -Message "Enter ePO Credentials:"
$epoUser=$Credential.GetNetworkCredential().username
$epoPassword=$Credential.GetNetworkCredential().password

#Creates WebClient to pass commands through
$wc=new-object System.net.WebClient
$wc.Credentials = new-object System.Net.NetworkCredential -ArgumentList ($epoUser, $epoPassword)

#Passes the computer name to the delete command, loops if credentials are entered incorrectly
$passed = $true
try {
$wc.DownloadString("$epoServer/remote/system.delete?names=$CompName")
}
catch [system.management.automation.methodinvocationexception] {
$error[0]
Write-Host "Username or password incorrect"
$passed = $false
}
}
}

#This function clears the Required PXE Deployments on the Computer object
Expand Down

0 comments on commit a6a780a

Please sign in to comment.