Skip to content

Instantly share code, notes, and snippets.

@virtualhobbit

virtualhobbit/osot.ps1

Last active Jun 17, 2020
Embed
What would you like to do?
$ErrorActionPreference = "Stop"
$webserver = "webserver.contoso.local"
$url = "http://" + $webserver
$files = @("VMwareOSOptimizationTool.exe","VMwareOSOptimizationTool.exe.config","my_osot.xml")
$exe = $files[0]
$arg = "-o -t " + $files[2]
# Verify connectivity
if (Test-Connection $webserver -Quiet){
# Get the OSOT files
ForEach ($file in $files)
{
Invoke-WebRequest -Uri ($url + "/" + $file) -OutFile $env:TEMP\$file
}
} else {
throw "No connection to server. Aborting."
}
# Change to temp folder
Set-Location $env:TEMP
# Run OSOT
Try
{
Start-Process $exe -ArgumentList $arg -Passthru -Wait -ErrorAction stop
}
Catch
{
Write-Error "Failed to run OSOT"
Write-Error $_.Exception
Exit -1
}
# Delete files
ForEach ($file in $files)
{
Remove-Item -Path $env:TEMP\$file -Confirm:$false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.