summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDon Schenck <don.schenck@gmail.com>2014-06-18 14:34:57 -0500
committerMatt Martz <matt@sivel.net>2014-06-19 14:25:27 -0500
commit5b15194a0d20cc5d28601e22e856fb7ad7bb0f93 (patch)
tree220cdc2666f1b3ea622eac5bbd63dd8b0f9f7d48 /examples
parent069fa71d873409ba97506465605f312b45557894 (diff)
downloadansible-5b15194a0d20cc5d28601e22e856fb7ad7bb0f93.tar.gz
PowerShell script to assure PowerShell 3 is installed
Will install PowerShell 3 if the machine has a lower version. WILL NOT do anything if PowerShell 3 (or higher) is already installed.
Diffstat (limited to 'examples')
-rw-r--r--examples/scripts/UpgradeToPS3.ps171
1 files changed, 71 insertions, 0 deletions
diff --git a/examples/scripts/UpgradeToPS3.ps1 b/examples/scripts/UpgradeToPS3.ps1
new file mode 100644
index 0000000000..5fe5dd5195
--- /dev/null
+++ b/examples/scripts/UpgradeToPS3.ps1
@@ -0,0 +1,71 @@
+# Upgrade to PowerShell 3.0
+
+# Get version of OS
+
+# 6.0 is 2008
+# 6.1 is 2008 R2
+# 6.2 is 2012
+# 6.3 is 2012 R2
+
+
+if ($PSVersionTable.psversion.Major -ge 3)
+{
+ write-host "Powershell 3 Installed already; You don't need this"
+ Exit
+}
+
+$powershellpath = "C:\powershell"
+
+function download-file
+{
+ param ([string]$path, [string]$local)
+ $client = new-object system.net.WebClient
+ $client.Headers.Add("user-agent", "PowerShell")
+ $client.downloadfile($path, $local)
+}
+
+if (!(test-path $powershellpath))
+{
+ New-Item -ItemType directory -Path $powershellpath
+}
+
+
+# .NET Framework 4.0 is necessary.
+
+if (($PSVersionTable.CLRVersion.Major) -lt 4)
+{
+ $DownloadUrl = "http://download.microsoft.com/download/B/A/4/BA4A7E71-2906-4B2D-A0E1-80CF16844F5F/dotNetFx45_Full_x86_x64.exe"
+ $FileName = $DownLoadUrl.Split('/')[-1]
+ download-file $downloadurl "$powershellpath\$filename"
+ ."$powershellpath\$filename" /quiet /norestart
+}
+
+#You may need to reboot after the .NET install if so just run the script again.
+
+# If the Operating System is above 6.2, then you already have PowerShell Version > 3
+if ([Environment]::OSVersion.Version.Major -gt 6)
+{
+ Exit
+}
+
+
+$osminor = [environment]::OSVersion.Version.Minor
+
+if ($osminor -eq 1)
+{
+ $DownloadUrl = "http://download.microsoft.com/download/3/D/6/3D61D262-8549-4769-A660-230B67E15B25/Windows6.1-KB2819745-x86-MultiPkg.msu"
+}
+elseif ($osminor -eq 0)
+{
+ $DownloadUrl = "http://download.microsoft.com/download/E/7/6/E76850B8-DA6E-4FF5-8CCE-A24FC513FD16/Windows6.0-KB2506146-x64.msu"
+}
+else
+{
+ # Nothing to do; In theory this point will never be reached.
+ Exit
+}
+
+$FileName = $DownLoadUrl.Split('/')[-1]
+download-file $downloadurl "$powershellpath\$filename"
+
+."$powershellpath\$filename" /quiet \ No newline at end of file