|
1 | | -function Write-Log { |
2 | | - Param ( |
3 | | - [Parameter(Mandatory=$True,Position=1)][string]$Message, |
4 | | - [string]$LogFile="C:\provision\log.log" |
5 | | - ) |
| 1 | +function Write-Log |
| 2 | +{ |
| 3 | + Param ( |
| 4 | + [Parameter(Mandatory = $True, Position = 1)][string]$Message, |
| 5 | + [string]$LogFile = "C:\provision\log.log" |
| 6 | + ) |
6 | 7 |
|
7 | | - $LogDir = (split-path $LogFile -parent) |
8 | | - If ((Test-Path $LogDir) -ne $True) { |
9 | | - New-Item -Path $LogDir -ItemType Directory -Force |
10 | | - } |
| 8 | + $LogDir = (split-path $LogFile -parent) |
| 9 | + If ((Test-Path $LogDir) -ne $True) |
| 10 | + { |
| 11 | + New-Item -Path $LogDir -ItemType Directory -Force |
| 12 | + } |
11 | 13 |
|
12 | | - $msg = "{0} {1}" -f (Get-Date -Format o), $Message |
13 | | - Add-Content -Path $LogFile -Value $msg -Encoding 'UTF8' |
14 | | - Write-Host $msg |
| 14 | + $msg = "{0} {1}" -f (Get-Date -Format o), $Message |
| 15 | + Add-Content -Path $LogFile -Value $msg -Encoding 'UTF8' |
| 16 | + Write-Host $msg |
15 | 17 | } |
16 | 18 |
|
| 19 | +$boshWinRMDir = 'C:\Program Files\WindowsPowerShell\Modules\BOSH.WinRM' |
| 20 | +Write-Log "Making bosh module directory: $boshWinRMDir" |
| 21 | +New-Item -Path $boshWinRMDir -ItemType Directory -Force |
| 22 | + |
17 | 23 | $winrmUrl = 'https://raw.githubusercontent.com/cloudfoundry/bosh-psmodules/master/modules/BOSH.WinRM/BOSH.WinRM.psm1' |
18 | | -Write-Log "Making bosh module directory" |
19 | | -$dir = 'C:\Program Files\WindowsPowerShell\Modules\BOSH.WinRM' |
20 | | -New-Item -Path $dir -ItemType Directory -Force |
21 | 24 |
|
22 | | -Write-Log "Fetching bosh module" |
23 | | -Invoke-WebRequest $winrmUrl -OutFile "$dir\BOSH.WinRM.psm1" |
| 25 | +Write-Log "Fetching bosh module $winrmUrl" |
| 26 | +Invoke-WebRequest $winrmUrl -OutFile "$boshWinRMDir\BOSH.WinRM.psm1" |
24 | 27 |
|
25 | | -if (-not(Get-Command Enable-WinRM -errorAction SilentlyContinue)) |
| 28 | +if (-not (Get-Command Enable-WinRM -errorAction SilentlyContinue)) |
26 | 29 | { |
27 | | - Write-Log "Enable-WinRM was not loaded. There may be a problem with $winrmUrl" |
| 30 | + Write-Log "Enable-WinRM was not loaded. There may be a problem with $winrmUrl" |
28 | 31 | } |
29 | 32 |
|
30 | | -Write-Log "Invoking winrm" |
| 33 | +Write-Log "Invoking WinRM" |
31 | 34 | Enable-WinRM |
0 commit comments