summaryrefslogtreecommitdiff
path: root/examples/scripts/upgrade_to_ps3.ps1
diff options
context:
space:
mode:
authorMichael DeHaan <michael.dehaan@gmail.com>2014-06-18 16:42:51 -0500
committerMatt Martz <matt@sivel.net>2014-06-19 14:25:49 -0500
commit128be9ea27277f40694847748ace56c0c01e6ae2 (patch)
tree227f9cce52e0d2c963d9420459d87db55c2b3493 /examples/scripts/upgrade_to_ps3.ps1
parent38338157b33111f06517b6216ca8c167a0d0276f (diff)
downloadansible-128be9ea27277f40694847748ace56c0c01e6ae2.tar.gz
File rename.
Diffstat (limited to 'examples/scripts/upgrade_to_ps3.ps1')
-rw-r--r--examples/scripts/upgrade_to_ps3.ps180
1 files changed, 80 insertions, 0 deletions
diff --git a/examples/scripts/upgrade_to_ps3.ps1 b/examples/scripts/upgrade_to_ps3.ps1
new file mode 100644
index 0000000000..1c938d64f1
--- /dev/null
+++ b/examples/scripts/upgrade_to_ps3.ps1
@@ -0,0 +1,80 @@
+
+# Powershell script to upgrade a PowerShell 2.0 system to PowerShell 3.0
+#
+# some Ansible modules that may use Powershell 3 features, so systems may need
+# to be upgraded. This may be used by a sample playbook. Refer to the windows
+# documentation on docs.ansible.com for details.
+#
+# - hosts: windows
+# tasks:
+# - script: upgrade_to_ps3.ps1
+
+# 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 2)
+#{
+# $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/E/7/6/E76850B8-DA6E-4FF5-8CCE-A24FC513FD16/Windows6.1-KB2506143-x64.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