-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4698684
commit 9f2a0b7
Showing
21 changed files
with
218 additions
and
169 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,72 @@ | ||
Function Get-WsbConfiguration { | ||
[cmdletbinding()] | ||
[outputType("wsbConfiguration")] | ||
[CmdletBinding()] | ||
[OutputType('wsbConfiguration')] | ||
Param( | ||
[Parameter(Position = 0, Mandatory, HelpMessage = "Specify the path to the .wsb file.")] | ||
[Parameter( | ||
Position = 0, | ||
Mandatory, | ||
ValueFromPipeline, | ||
HelpMessage = 'Specify the path to the .wsb file.' | ||
)] | ||
[ValidatePattern('\.wsb$')] | ||
[ValidateScript( { Test-Path $_ })] | ||
[ArgumentCompleter( { if (Test-Path $global:wsbConfigPath) { (Get-ChildItem $Global:wsbConfigPath).fullname } })] | ||
[string]$Path, | ||
[Parameter(HelpMessage = "Only display metadata information.")] | ||
[switch]$MetadataOnly | ||
[ArgumentCompleter( { if (Test-Path $global:wsbConfigPath) { (Get-ChildItem $Global:wsbConfigPath).FullName } })] | ||
[String]$Path, | ||
|
||
[Parameter(HelpMessage = 'Only display metadata information.')] | ||
[Switch]$MetadataOnly | ||
) | ||
|
||
$cPath = Convert-Path $Path | ||
Write-Verbose "Getting configuration from $cPath" | ||
Begin { | ||
Write-Verbose "[$((Get-Date).TimeOfDay) BEGIN ] Starting $($MyInvocation.MyCommand)" | ||
} #begin | ||
Process { | ||
|
||
$cPath = Convert-Path $Path | ||
Write-Verbose "Getting configuration from $cPath" | ||
|
||
[xml]$wsb = Get-Content -Path $cPath | ||
[xml]$wsb = Get-Content -Path $cPath | ||
|
||
Write-Verbose "Building property list" | ||
$properties = [System.Collections.Generic.List[object]]::new() | ||
$properties.AddRange($wsb.configuration.psadapted.psobject.properties.name) | ||
if ($properties.Contains("LogonCommand")) { | ||
[void]($properties.Remove("LogonCommand")) | ||
$properties.Add(@{Name = "LogonCommand"; Expression = { $wsb.configuration.logonCommand.Command } }) | ||
} | ||
if ($properties.Contains("MappedFolders")) { | ||
[void]($properties.Remove("MappedFolders")) | ||
$properties.Add(@{Name = "MappedFolder"; Expression = { | ||
$wsb.Configuration.MappedFolders.MappedFolder | | ||
Select-Object *folder,@{Name="ReadOnly";Expression = { if ($_.ReadOnly -eq 'True') { $True } else {$False}}} | | ||
New-WsbMappedFolder | New-WsbMappedFolder } }) | ||
} | ||
Write-Verbose 'Building property list' | ||
$properties = [System.Collections.Generic.List[object]]::new() | ||
$properties.AddRange($wsb.configuration.PSAdapted.PSObject.properties.name) | ||
if ($properties.Contains('LogonCommand')) { | ||
[void]($properties.Remove('LogonCommand')) | ||
$properties.Add(@{Name = 'LogonCommand'; Expression = { $wsb.configuration.logonCommand.Command } }) | ||
} | ||
if ($properties.Contains('MappedFolders')) { | ||
[void]($properties.Remove('MappedFolders')) | ||
$properties.Add(@{Name = 'MappedFolder'; Expression = { | ||
$wsb.Configuration.MappedFolders.MappedFolder | | ||
Select-Object *folder, @{Name = 'ReadOnly'; Expression = { if ($_.ReadOnly -eq 'True') { $True } else { $False } } } | | ||
New-WsbMappedFolder | New-WsbMappedFolder } | ||
}) | ||
} | ||
|
||
Write-Verbose "Get metadata information" | ||
if ($wsb.configuration.metadata) { | ||
Write-Verbose "Existing metadata found" | ||
$meta = [wsbMetadata]::new($wsb.Configuration.metadata.Name, $wsb.configuration.metadata.Description) | ||
$meta.updated = $wsb.configuration.metadata.updated | ||
$meta.author = $wsb.configuration.metadata.author | ||
} | ||
else { | ||
Write-Verbose "Defining new metadata" | ||
$meta = [wsbMetadata]::new($cPath) | ||
$meta.updated = Get-Date | ||
} | ||
Write-Verbose 'Get metadata information' | ||
if ($wsb.configuration.metadata) { | ||
Write-Verbose 'Existing metadata found' | ||
$meta = [wsbMetadata]::new($wsb.Configuration.metadata.Name, $wsb.configuration.metadata.Description) | ||
$meta.updated = $wsb.configuration.metadata.updated | ||
$meta.author = $wsb.configuration.metadata.author | ||
} | ||
else { | ||
Write-Verbose 'Defining new metadata' | ||
$meta = [wsbMetadata]::new($cPath) | ||
$meta.updated = Get-Date | ||
} | ||
|
||
if ($MetadataOnly) { | ||
Write-Verbose "Displaying metadata only" | ||
$meta | ||
} | ||
else { | ||
Write-Verbose "Sending configuration to New-WsbConfiguration" | ||
$wsb.configuration | Select-Object -Property $properties | New-WsbConfiguration -metadata $meta | ||
Write-Verbose "Ending $($myinvocation.mycommand)" | ||
} | ||
if ($MetadataOnly) { | ||
Write-Verbose 'Displaying metadata only' | ||
$meta | ||
} | ||
else { | ||
Write-Verbose 'Sending configuration to New-WsbConfiguration' | ||
$wsb.configuration | Select-Object -Property $properties | New-WsbConfiguration -metadata $meta | ||
Write-Verbose "Ending $($MyInvocation.MyCommand)" | ||
} | ||
} #process | ||
End { | ||
Write-Verbose "[$((Get-Date).TimeOfDay) END ] Ending $($MyInvocation.MyCommand)" | ||
} #end | ||
} |
Oops, something went wrong.