PSHonolulu.psm1
Write-Verbose 'Importing from [C:\projects\pshonolulu\PSHonolulu\private]' Write-Verbose 'Importing from [C:\projects\pshonolulu\PSHonolulu\public]' # .\PSHonolulu\public\Get-HonoluluServer.ps1 function Get-HonoluluServer { <# .SYNOPSIS Get the Honolulu Server connection information .DESCRIPTION Get the confgiured Honolulu Server settings .EXAMPLE Get-HonoluluServer This will set the local computer as the Project Honolulu server .NOTES General notes #> [CmdletBinding()] param( ) begin { $path = Join-Path $env:homedrive $env:HOMEPATH $path = Join-Path $path '.pshonolulu' } process { try { If ( Test-Path $path -ErrorAction Ignore ) { Get-Content $path | ConvertFrom-JSON } else { [pscustomobject]@{ ComputerName = $env:COMPUTERNAME Port = 6516 } } } catch { $PSCmdlet.ThrowTerminatingError( $PSItem ) } } } # .\PSHonolulu\public\Set-HonoluluServer.ps1 function Set-HonoluluServer { <# .SYNOPSIS Set the Honolulu Server connection information .DESCRIPTION Configure the local system to use a specified Honolulu Server .PARAMETER ComputerName The server name. Use localhost if this system is running the service .PARAMETER Port The port that Project Honolulu is listening on .EXAMPLE Set-HonoluluServer -ComputerName $env:ComputerName -Port 6516 This will set the local computer as the Project Honolulu server .NOTES General notes #> [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")] [CmdletBinding()] param( $ComputerName = $env:COMPUTERNAME, $Port = 6516 ) begin { $path = Join-Path $env:homedrive $env:HOMEPATH $path = Join-Path $path '.pshonolulu' } process { try { $settings = @{ ComputerName = $ComputerName Port = $Port } $settings | ConvertTo-Json | Set-Content -Path $path } catch { $PSCmdlet.ThrowTerminatingError( $PSItem ) } } } # .\PSHonolulu\public\Show-Computer.ps1 function Show-Computer { <# .SYNOPSIS Show specified computer in Honolulu .DESCRIPTION Takes the specified computer and crafts the needed URL to load it in Project Honolulu .PARAMETER ComputerName Parameter description .PARAMETER View The view to show by default. .EXAMPLE Show-Computer Will show the local computer in Project Honolulu .EXAMPLE Show-Computer -ComputerName server02 .NOTES General notes #> [CmdletBinding()] param( [parameter( ValueFromPipeline )] [alias('ServerName', 'CN')] [string[]] $ComputerName = $env:COMPUTERNAME, [ValidateSet( 'overview', 'certificates', 'devices', 'Events', 'Files', 'Firewall', 'UsersGroups', 'Network', 'Processes', 'Registry', 'RolesFeatures', 'Services', 'Storage', 'StorageReplica', 'VirtualMachines', 'VirtualSwitches', 'WindowsUpdate' )] [string] $View = 'overview' ) begin { $info = Get-HonoluluServer $uri = 'http://{0}:{1}' -f $info.ComputerName, $info.Port $View = $View.ToLower() } process { try { foreach ( $node in $ComputerName ) { Start-Process "$uri/servermanager/connections/server/$node/tools/$View" } } catch { $PSCmdlet.ThrowTerminatingError( $PSItem ) } } } Write-Verbose 'Importing from [C:\projects\pshonolulu\PSHonolulu\classes]' |