Skip to content

Commit a913df8

Browse files
committed
Powershell: normalize powershell style
1 parent 7794000 commit a913df8

26 files changed

+1137
-883
lines changed

ci/tasks/test-units-bosh-psmodules/run.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ foreach ($module in $testModules) {
2323
# Do not set $ErrorActionPreference and let Pester handle it nativetly; setting it to Stop globally will
2424
# break the tests since they are written with the assumption non zero exit codes will not fail a test
2525
# See: https://github.com/pester/Pester/issues/1404#issuecomment-568659518 for details
26-
$results=Invoke-Pester -PassThru
26+
$results=Invoke-Pester -PassThru # append "-Output Diagnostic" for verbose output
2727
if ($results.FailedCount -gt 0) {
2828
$result += $results.FailedCount
2929
}

modules/BOSH.Account/BOSH.Account.Tests.ps1

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ Describe "BOSH.Account" {
2525

2626
Context "when the username and password are valid" {
2727
BeforeAll {
28-
$timestamp=(get-date -UFormat "%s" -Millisecond 0)
28+
$timestamp = (get-date -UFormat "%s" -Millisecond 0)
2929
$user = "TestUser_$timestamp"
3030
$password = "Password123!"
3131
}
3232

33-
BeforeEach {
34-
$userExists = !!(Get-LocalUser | Where {$_.Name -eq $user})
35-
if($userExists) {
33+
BeforeEach {
34+
$userExists = !!(Get-LocalUser | Where { $_.Name -eq $user })
35+
if ($userExists)
36+
{
3637
Remove-LocalUser -Name $user
3738
}
3839
}
@@ -41,10 +42,10 @@ Describe "BOSH.Account" {
4142
Add-Account -User $user -Password $password
4243
mkdir "C:\Users\$user" -ErrorAction Ignore
4344
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
44-
$existing = $adsi.Children | Where-Object {$_.SchemaClassName -eq 'user' -and $_.Name -eq $user }
45+
$existing = $adsi.Children | Where-Object { $_.SchemaClassName -eq 'user' -and $_.Name -eq $user }
4546
$existing | Should -Not -Be $null
4647
Remove-Account -User $user
47-
$existing = $adsi.Children | Where-Object {$_.SchemaClassName -eq 'user' -and $_.Name -eq $user }
48+
$existing = $adsi.Children | Where-Object { $_.SchemaClassName -eq 'user' -and $_.Name -eq $user }
4849
$existing | Should -Be $null
4950
}
5051
}
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
@{
2-
RootModule = 'BOSH.Account'
3-
ModuleVersion = '0.1'
4-
GUID = 'ebdf7a79-39df-46ce-a046-42dd10de82ce'
5-
Author = 'BOSH'
6-
Copyright = '(c) 2017 BOSH'
7-
Description = 'Commands for creating a new Windows user'
8-
PowerShellVersion = '4.0'
9-
RequiredModules = @('BOSH.Utils')
10-
FunctionsToExport = @('Add-Account','Remove-Account')
11-
CmdletsToExport = @()
12-
VariablesToExport = '*'
13-
AliasesToExport = @()
14-
PrivateData = @{
15-
PSData = @{
16-
Tags = @('BOSH')
17-
LicenseUri = 'https://github.com/cloudfoundry/bosh-windows-stemcell-builder/blob/master/LICENSE'
18-
ProjectUri = 'https://github.com/cloudfoundry/bosh-windows-stemcell-builder'
2+
RootModule = 'BOSH.Account'
3+
ModuleVersion = '0.1'
4+
GUID = 'ebdf7a79-39df-46ce-a046-42dd10de82ce'
5+
Author = 'BOSH'
6+
Copyright = '(c) 2017 BOSH'
7+
Description = 'Commands for creating a new Windows user'
8+
PowerShellVersion = '4.0'
9+
RequiredModules = @('BOSH.Utils')
10+
FunctionsToExport = @('Add-Account', 'Remove-Account')
11+
CmdletsToExport = @()
12+
VariablesToExport = '*'
13+
AliasesToExport = @()
14+
PrivateData = @{
15+
PSData = @{
16+
Tags = @('BOSH')
17+
LicenseUri = 'https://github.com/cloudfoundry/bosh-windows-stemcell-builder/blob/master/LICENSE'
18+
ProjectUri = 'https://github.com/cloudfoundry/bosh-windows-stemcell-builder'
19+
}
1920
}
2021
}
21-
}

modules/BOSH.Account/BOSH.Account.psm1

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
.Description
55
This cmdlet adds a Windows user
66
#>
7-
function Add-Account {
7+
function Add-Account
8+
{
89
Param(
9-
[string]$User = $(Throw "Provide a user name"),
10-
[string]$Password = $(Throw "Provide a password")
11-
)
10+
[string]$User = $( Throw "Provide a user name" ),
11+
[string]$Password = $( Throw "Provide a password" )
12+
)
1213
Write-Log "Add-Account"
1314

1415
Write-Log "Creating new local user $User."
@@ -19,9 +20,9 @@ function Add-Account {
1920
Write-Log "Adding local user $User to $Group."
2021
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"
2122
Write-Log $adsi
22-
$AdminGroup = $adsi.Children | Where-Object {$_.SchemaClassName -eq 'group' -and $_.Name -eq $Group }
23+
$AdminGroup = $adsi.Children | Where-Object { $_.SchemaClassName -eq 'group' -and $_.Name -eq $Group }
2324
Write-Log $AdminGroup
24-
$UserObject = $adsi.Children | Where-Object {$_.SchemaClassName -eq 'user' -and $_.Name -eq $User }
25+
$UserObject = $adsi.Children | Where-Object { $_.SchemaClassName -eq 'user' -and $_.Name -eq $User }
2526
Write-Log $UserObject
2627
$AdminGroup.Add($UserObject.Path)
2728
Write-Log "Completed adding $User to $Group"
@@ -33,10 +34,11 @@ Remove Windows user
3334
.Description
3435
This cmdlet removes a Windows user
3536
#>
36-
function Remove-Account {
37+
function Remove-Account
38+
{
3739
Param(
38-
[string]$User = $(Throw "Provide a user name")
39-
)
40+
[string]$User = $( Throw "Provide a user name" )
41+
)
4042
Write-Log "Remove-Account"
4143
Write-Log "Removing local user $User."
4244
$adsi = [ADSI]"WinNT://$env:COMPUTERNAME"

modules/BOSH.Agent/BOSH.Agent.psd1

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
@{
2-
RootModule = 'BOSH.Agent'
3-
ModuleVersion = '0.1'
4-
GUID = 'f46b71ee-4312-4f80-34c7-665d64250ae8'
5-
Author = 'BOSH'
6-
Copyright = '(c) 2017 BOSH'
7-
Description = 'Install BOSH-Agent on a BOSH deployed vm'
8-
PowerShellVersion = '4.0'
9-
RequiredModules = @('BOSH.Utils')
10-
FunctionsToExport = @('Install-Agent','Enable-AgentService','Disable-AgentService')
11-
CmdletsToExport = @()
12-
VariablesToExport = '*'
13-
AliasesToExport = @()
14-
PrivateData = @{
15-
PSData = @{
16-
Tags = @('BOSH')
17-
LicenseUri = 'https://github.com/cloudfoundry/bosh-windows-stemcell-builder/blob/master/LICENSE'
18-
ProjectUri = 'https://github.com/cloudfoundry/bosh-windows-stemcell-builder'
2+
RootModule = 'BOSH.Agent'
3+
ModuleVersion = '0.1'
4+
GUID = 'f46b71ee-4312-4f80-34c7-665d64250ae8'
5+
Author = 'BOSH'
6+
Copyright = '(c) 2017 BOSH'
7+
Description = 'Install BOSH-Agent on a BOSH deployed vm'
8+
PowerShellVersion = '4.0'
9+
RequiredModules = @('BOSH.Utils')
10+
FunctionsToExport = @('Install-Agent', 'Enable-AgentService', 'Disable-AgentService')
11+
CmdletsToExport = @()
12+
VariablesToExport = '*'
13+
AliasesToExport = @()
14+
PrivateData = @{
15+
PSData = @{
16+
Tags = @('BOSH')
17+
LicenseUri = 'https://github.com/cloudfoundry/bosh-windows-stemcell-builder/blob/master/LICENSE'
18+
ProjectUri = 'https://github.com/cloudfoundry/bosh-windows-stemcell-builder'
19+
}
1920
}
2021
}
21-
}

0 commit comments

Comments
 (0)