Advertisement
jmeg8r

Set-Crypto

Aug 9th, 2018 (edited)
2,103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ?#Author: James Cruce
  2. #Date: 6/27/2018
  3. # Version 1.0
  4. # Script assumes you have vCenter admin rights and are currently connected to the vCenter with all the vms in the vms.txt file
  5. # The script will load the list of vms to configure cipher settings and then copy over the needed IISCrypto CLI program ( https://www.nartac.com/Products/IISCrypto ) as well as the needed template files and the bat files to execute the IISCrypto cli command which will apply the correct template on the operating system version. It will then clean up the unneeded files and IISCrypto folder on the remote vm. It will loop through the entire list until completed.
  6.  
  7.  
  8.  
  9. $vmname = $null
  10.  
  11. $name = $null
  12.  
  13. $vms = $null
  14.  
  15. $wmi = $null
  16.  
  17.  
  18.  
  19. $vms = get-content -Path C:\IISCrypto\vms.txt
  20.  
  21.  
  22.  
  23. foreach ($vm in $vms)
  24. {
  25.     $name = Get-VM $vm
  26.     $vmname = ($name.name)
  27.  
  28.     Write-Verbose -Message "Starting copy of needed IISCrypto files for $vmname" -Verbose
  29.  
  30.     Copy-Item \\fileserver\IISCryptoShare\ -Destination \\$vmname\c$ -Recurse
  31.  
  32.     $wmi = Get-WmiObject -Query "select Version from Win32_OperatingSystem" -ComputerName $vmname
  33.  
  34.  
  35.  
  36.     If (($wmi.version) -like "*10.*")
  37.     {
  38.         Write-Verbose -Message 'Configuring CipherSuite Settings' -Verbose
  39.         $ConfigCipherSuites = 'C:\IISCrypto\ConfigCrypto16.bat'
  40.         Invoke-VMScript -ScriptText $ConfigCipherSuites -VM $vmname -ScriptType Bat
  41.     }
  42.  
  43.     If (($wmi.version) -like "*6.*")
  44.     {
  45.         Write-Verbose -Message 'Configuring CipherSuite Settings' -Verbose
  46.         $ConfigCipherSuites = 'C:\IISCrypto\ConfigCrypto12.bat'
  47.         Invoke-VMScript -ScriptText $ConfigCipherSuites -VM $vmname -ScriptType Bat
  48.  
  49.     }
  50.  
  51.  
  52.     Write-Verbose -Message "Cleaning Up IISCrypto Folder and Files on $vmname" -Verbose
  53.     $DelIISCrypto = 'Remove-Item C:\IISCrypto\* -Recurse;
  54.                   Remove-Item C:\IISCrypto'
  55.  
  56.     Invoke-VMScript -ScriptText $DelIISCrypto -VM $vmname -ScriptType Powershell
  57.  
  58. }
  59.  
  60. Write-Verbose -Message 'The script is finished' -Verbose
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement