update
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
"target_platform","target_hostname","target_cpus","target_memory","target_osdisk","target_datadisk","target_subnet","target_os","target_environment","target_vm_app_name","target_datacenter","target_licensingrestrictions"
|
||||
"VMware","itdzmtest110.nd.gov","1","4","50","20","10.11.12.0/23","Windows Server 2022 Datacenter","Production","ITD-POC-zmeier","Bismarck","No Licensing Restrictions"
|
||||
|
+64
@@ -0,0 +1,64 @@
|
||||
$DriveLetter = 'D'
|
||||
$CsvPath = ($DriveLetter + ":\AutoBuildInputFiles\")
|
||||
$FailedPath = ($DriveLetter + ":\AutoBuildInputFiles\Failed")
|
||||
$CompletedPath = ($DriveLetter + ":\AutoBuildInputFiles\Completed")
|
||||
|
||||
$GetBuildFile = Get-ChildItem -Path $CsvPath -Filter *.csv | Sort-Object LastWriteTime | select -First 1
|
||||
|
||||
#$IaasAutoCred = Get-AutomationPSCredential -Name 'ITD Iaas Automation'
|
||||
$IaasAutoCred = $PrvCred
|
||||
|
||||
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -ParticipateInCeip $false -Confirm:$false -InvalidCertificateAction Ignore
|
||||
|
||||
$InputParams = Import-Csv -Path $GetBuildFile.FullName
|
||||
|
||||
$ComputerName = $InputParams.target_hostname.ToLower()
|
||||
Send-MailMessage -From "zmauto@nd.gov" -To "zmeier@nd.gov" -SmtpServer apprelay1.nd.gov -Body $InputParams -Subject ("AutoBuildFromFile-$ComputerName-" + $InputParams.target_platform)
|
||||
|
||||
try {
|
||||
switch ($InputParams.target_platform) {
|
||||
'azure' {
|
||||
|
||||
}
|
||||
'vmware' {
|
||||
Connect-VIServer -Server itdvmvc1.nd.gov, itdvmvc2.nd.gov -Credential $IaasAutoCred
|
||||
|
||||
New-ITDVMwareWindowsVM -ComputerName $ComputerName `
|
||||
-CPU $InputParams.target_cpus `
|
||||
-MemoryGB $InputParams.target_memory `
|
||||
-DiskOS $InputParams.target_osdisk `
|
||||
-DiskData $InputParams.target_datadisk `
|
||||
-Subnet $InputParams.target_subnet `
|
||||
-OS $InputParams.target_os `
|
||||
-Environment $InputParams.target_environment `
|
||||
-Datacenter $InputParams.target_datacenter `
|
||||
-AppName $InputParams.target_vm_app_name `
|
||||
-LicensingRestrictions $InputParams.target_licensingrestrictions `
|
||||
-Credential $IaasAutoCred `
|
||||
-Verbose
|
||||
|
||||
Move-Item -Path $GetBuildFile.FullName -Destination $CompletedPath
|
||||
|
||||
$postParams = [PSCustomObject]@{
|
||||
AutomationName = "Infra-VMware";
|
||||
Action = 'Provisioning';
|
||||
Units = 240;
|
||||
Platform = 'PowerShell-VMware-VMWindows';
|
||||
}
|
||||
|
||||
Invoke-RestMethod -Uri http://itdnettools.nd.gov/services/automation-tracking.py -Method POST -Body ($postParams | ConvertTo-Json)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
$error[0]
|
||||
Write-Warning "Email vmware admins about failure"
|
||||
$Body = $error[0] | Select-Object *
|
||||
Send-MailMessage -From autobuild@nd.gov -To "zmeier@nd.gov" -Subject "Failure-AutoBuildFromFile-$ComputerName" -SmtpServer apprelay.nd.gov -Body $Body
|
||||
|
||||
Write-Warning "Error detected. Moving csv input file to folder Failed"
|
||||
Move-Item -Path $GetBuildFile.FullName -Destination $FailedPath
|
||||
}
|
||||
|
||||
Disconnect-VIServer -Server * -Confirm:$false -ErrorAction SilentlyContinue
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
$RestMethodParams = @{
|
||||
Method = 'Post';
|
||||
Uri = 'https://96bdfe01-af80-4575-8f23-e7057184c8f6.webhook.cus.azure-automation.net/webhooks?token=4cWZz%2fq97AqMdlNak6qv2lUurLPFsWmPJmovLmAE%2fNg%3d';
|
||||
Headers = @{ITD = 'mXJU74ABYyDHcVY6iJihPDk8LidJ2ibBA2sA3RAwKaBHS6Gw7Rr2Zz5JZAhPm6wMuvY7X54ZzJxAXaM7ig3PHG4MKvtkBf8X7q3jGNcePgUqg9WCwCSJ3JWG7AA6M39x4vpihKeZV' };
|
||||
Body = [PSCustomObject]@{
|
||||
target_platform = "VMware"
|
||||
target_hostname = 'itdcndsperms.nd.gov';
|
||||
target_cpus = 1;
|
||||
target_memory = 8;
|
||||
target_osdisk = 100;
|
||||
target_datadisk = 20; # this is now swap
|
||||
target_subnet = '10.221.8.0/28';
|
||||
target_os = 'Windows Server 2019 Datacenter';
|
||||
target_environment = 'Production';
|
||||
target_vm_app_name = 'Shared-PeopleSoft-State';
|
||||
target_datacenter = 'Bismarck';
|
||||
target_licensingrestrictions = 'No Licensing Restrictions';
|
||||
} | ConvertTo-Json;
|
||||
}
|
||||
|
||||
Invoke-RestMethod @RestMethodParams
|
||||
|
||||
$VMNames=@"
|
||||
itdcndhftdb22.nd.gov
|
||||
itdcndhhtdb22.nd.gov
|
||||
"@
|
||||
$VMNames = ConvertTo-Array -MultiLineString $VMNames
|
||||
|
||||
Invoke-Command -ComputerName $VMNames -Credential $PrvCred -ScriptBlock {
|
||||
Get-Process -Name ccmexec*,cohesity*,cortex*,nessus*,vmtoolsd*
|
||||
} | sort-object PSComputerName
|
||||
+1131
File diff suppressed because it is too large
Load Diff
+23
@@ -0,0 +1,23 @@
|
||||
#https://96bdfe01-af80-4575-8f23-e7057184c8f6.webhook.cus.azure-automation.net/webhooks?token=4cWZz%2fq97AqMdlNak6qv2lUurLPFsWmPJmovLmAE%2fNg%3d
|
||||
[CmdletBinding()]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $false)]
|
||||
[object] $WebhookData
|
||||
)
|
||||
|
||||
If ($WebhookData) {
|
||||
If ($WebhookData.RequestHeader.ITD -eq 'mXJU74ABYyDHcVY6iJihPDk8LidJ2ibBA2sA3RAwKaBHS6Gw7Rr2Zz5JZAhPm6wMuvY7X54ZzJxAXaM7ig3PHG4MKvtkBf8X7q3jGNcePgUqg9WCwCSJ3JWG7AA6M39x4vpihKeZV') {
|
||||
Write-Verbose "Header has required data"
|
||||
Write-Host $
|
||||
}
|
||||
Else {
|
||||
Write-Error "Header missing required data"
|
||||
exit;
|
||||
}
|
||||
|
||||
$InputParams = (ConvertFrom-Json -InputObject $WebhookData.RequestBody)
|
||||
$ComputerName = $InputParams.target_hostname.ToLower()
|
||||
$TimeStamp = Get-Date -UFormat "%Y%m%d%H%M%S"
|
||||
$InputParams | Export-Csv "E:\AutoBuildInputFiles\$ComputerName-$Timestamp.csv"
|
||||
}
|
||||
Reference in New Issue
Block a user