Last active
August 29, 2015 14:01
-
-
Save bdwyertech/286f98f2148c30806460 to your computer and use it in GitHub Desktop.
Set SSL_CERT_FILE for Vagrant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Filename: Set-SSLCert_Chef_Vagrant.ps1 | |
# Brian Dwyer - 5/22/14 | |
# ***USAGE*** | |
# To Setup the SSL_CERT_FILE Variable | |
# ./Set-SSLCert_Chef_Vagrant.ps1 set | |
# To Remove the SSL_CERT_FILE Variable | |
# ./Set-SSLCert_Chef_Vagrant.ps1 unset | |
# System-Wide Environmental Variables | |
$System_Vars='HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' | |
# User-Specific Environmental Variables | |
$User_Vars='HKCU:\Environment' | |
# Check if Vagrant is installed | |
If (!$env:Path.Contains('Vagrant')) | |
{ | |
echo "" | |
echo "/======| Error: Vagrant does not seem to be installed. |=====\" | |
echo "" | |
pause | |
exit | |
} | |
# Get Vagrant Installation Directory | |
$Vagrant_DIR = $env:Path.Split(';') -like "*vagrant*" | Out-String -Stream | Split-Path -Parent | |
# Registry Property Key/Value | |
$Reg_Key='SSL_CERT_FILE' | |
$Reg_Value="$Vagrant_DIR\embedded\cacert.pem" | |
# Setup | |
If ( $args[0] -eq 'set' ) | |
{ | |
echo "/======| Setting up Registry Key... |=====\" | |
Set-ItemProperty $User_Vars -Name $Reg_Key -Value $Reg_Value | |
pause | |
} | |
Elseif ( $args[0] -eq 'unset' ) | |
{ | |
echo "/======| Removing Registry Key... |=====\" | |
Remove-ItemProperty $User_Vars -Name $Reg_Key | |
pause | |
} | |
Else | |
{ | |
echo '------------------------------------------------' | |
echo "|*|-Set SSL_CERT_FILE Environmental Variable-|*|" | |
echo '------------------------------------------------' | |
echo "| Use 'set' or 'unset' to control script |" | |
echo '------------------------------------------------' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment