Skip to content

Commit 0d79550

Browse files
committed
Merge branch 'release/server-core-update'
2 parents c63994b + 5dd4476 commit 0d79550

File tree

276 files changed

+102906
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

276 files changed

+102906
-9
lines changed

PSScriptAnalyzerSettings.psd1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@{
2+
# Use Severity when you want to limit the generated diagnostic records to a
3+
# subset of: Error, Warning and Information.
4+
# Uncomment the following line if you only want Errors and Warnings but
5+
# not Information diagnostic records.
6+
Severity = @('Error', 'Warning')
7+
8+
# Use IncludeRules when you want to run only a subset of the default rule set.
9+
#IncludeRules = @('PSAvoidDefaultValueSwitchParameter',
10+
# 'PSMissingModuleManifestField',
11+
# 'PSReservedCmdletChar',
12+
# 'PSReservedParams',
13+
# 'PSShouldProcess',
14+
# 'PSUseApprovedVerbs',
15+
# 'PSUseDeclaredVarsMoreThanAssigments')
16+
17+
# Use ExcludeRules when you want to run most of the default set of rules except
18+
# for a few rules you wish to "exclude". Note: if a rule is in both IncludeRules
19+
# and ExcludeRules, the rule will be excluded.
20+
#ExcludeRules = @('PSAvoidUsingWriteHost', 'PSAvoidGlobalVars')
21+
22+
# You can use the following entry to supply parameters to rules that take parameters.
23+
# For instance, the PSAvoidUsingCmdletAliases rule takes a whitelist for aliases you
24+
# want to allow.
25+
Rules = @{
26+
# Do not flag 'cd' alias.
27+
# PSAvoidUsingCmdletAliases = @{Whitelist = @('cd')}
28+
29+
# Check if your script uses cmdlets that are compatible on PowerShell Core, version 6.0.0-alpha, on Linux.
30+
PSUseCompatibleCmdlets = @{
31+
Compatibility = @(
32+
"core-6.0.0-alpha-linux",
33+
"core-6.0.0-alpha-osx",
34+
"core-6.0.0-alpha-windows"
35+
#"desktop-5.1.14393.206-windows"
36+
)
37+
}
38+
}
39+
}

powercli-windowsservercore/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ RUN Write-Output 'Setting up environment...'; \
1818
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; \
1919
Install-Module GitHubRepository -Force -Confirm:$false; \
2020
Install-Module VMware.PowerCLI -Force -Confirm:$false; \
21-
Install-Module powervra -Force -Confirm:$false; \
22-
Install-Module powervro -Force -Confirm:$false; \
23-
Install-GitHubRepository -Owner vmware -Repository powernsx -Branch master -DestinationPath $env:programfiles\WindowsPowerShell\Modules; \
21+
Install-Module PowerNSX -Force -Confirm:$false; \
22+
Install-Module PowervRA -Force -Confirm:$false; \
23+
Install-Module PowervRO -Force -Confirm:$false; \
2424
mkdir c:\src; \
2525
Install-GitHubRepository -Owner vmware -Repository PowerCLI-Example-Scripts -Branch master -DestinationPath c:\src\; \
2626
Rename-Item c:\src\PowerCLI-Example-Scripts vmware -Force; \

powercli-windowsservercore/PSEnv.Functions.ps1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ function Start-Environment {
5454
[System.String[]]
5555
$moduleList = @(
5656
'VMware.PowerCLI',
57-
'powernsx',
58-
'powervro',
59-
'powervra'
57+
'PowerNSX',
58+
'PowervRO',
59+
'PowervRA'
6060
)
6161
)
6262

@@ -83,9 +83,9 @@ function Get-Environment {
8383
[System.String[]]
8484
$moduleList = @(
8585
'VMware*',
86-
'powernsx',
87-
'powervro',
88-
'powervra'
86+
'PowerNSX',
87+
'PowervRO',
88+
'PowervRA'
8989
)
9090
)
9191

vester-ws-nano/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM microsoft/nanoserver
2+
3+
# Setup metadata (MAINTAINER is deprecated)
4+
LABEL \
5+
author="Kevin Kirkpatrick" \
6+
description="This image is pre-configured with PowerShell \
7+
Modules maintained by VMware, as well as the \
8+
VMware community."
9+
10+
# copy modules from build dir; couldn't get Expand-Archive to work correctly in nano server, thus, no auto-install
11+
COPY Vester /Modules/Vester
12+
COPY PowerCLI.ViCore /Modules/PowerCLI.ViCore
13+
COPY PowerCLI.Cis /Modules/PowerCLI.Cis
14+
COPY PowerCLI.Vds /Modules/PowerCLI.Vds
15+
16+
# set powershell to run on container start
17+
CMD ["C:\\windows\\system32\\windowspowershell\\v1.0\\powershell.exe"]
18+
19+
# setup shell environment to PowerShell for RUN commands
20+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
21+
22+
# setup remainder of environment
23+
RUN Write-Output 'Setting up environment...'; \
24+
mkdir $home\Documents\WindowsPowerShell\Modules | Out-Null; \
25+
mkdir C:\Users\ContainerAdministrator\AppData\Roaming\VMware\PowerCLI | Out-Null; \
26+
Get-ChildItem C:\Modules -Directory -Filter PowerCLI* | foreach { Move-Item $_.FullName $env:programfiles\WindowsPowerShell\Modules -Force}; \
27+
Get-ChildItem C:\Modules -Directory -Filter Vester | foreach { Move-Item $_.FullName $home\Documents\WindowsPowerShell\Modules -Force}; \
28+
Get-Item C:\Modules | Remove-Item -Force; \
29+
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; \
30+
Install-Module powervra -Force -Confirm:$false; \
31+
Install-Module powervro -Force -Confirm:$false; \
32+
Install-Module Pester -Force -Confirm:$false -SkipPublisherCheck;
33+
34+
# copy PowerCLI settings file over which enables CEIP, by default (also provides a cleaner startup experience)
35+
COPY PowerCLI_Settings.xml /Users/ContainerAdministrator/AppData/Roaming/VMware/PowerCLI
36+
37+
# setup PowerShell Profile
38+
COPY PSEnv.Functions.ps1 /Users/ContainerAdministrator/Documents/WindowsPowerShell
39+
COPY Microsoft.PowerShell_profile.ps1 /Users/ContainerAdministrator/Documents/WindowsPowerShell
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# generic globl powershell profile
2+
3+
# created 20160421 - Kevin Kirkpatrick (Twitter|GitHub @vScriper)
4+
5+
# create PSDrive and set it as the starting location
6+
if (Test-Path 'c:\src\vmware'){
7+
[void](New-PSDrive -Name P -PSProvider FileSystem -Root 'c:\src\vmware')
8+
Set-Location P:\
9+
}
10+
11+
# import profile configuration
12+
$profileFunctionsPath = Join-Path $PSScriptRoot 'PSEnv.Functions.ps1'
13+
14+
if (Test-Path $profileFunctionsPath){
15+
Import-Module $profileFunctionsPath
16+
} else {
17+
throw "Functions File Not Found {$profileFunctionsPath}"
18+
} # end if
19+
20+
# Import proper version of Pester
21+
[void](Import-Module -FullyQualifiedName @{ModuleName='Pester';ModuleVersion='4.0.3'})
22+
[void](Import-Module Vester)
23+
24+
# setup custom console colors
25+
$hostUI = $host.PrivateData
26+
$hostUI.ErrorForegroundColor = 'White'
27+
$hostUI.ErrorBackgroundColor = 'Red'
28+
$hostUI.DebugForegroundColor = 'White'
29+
$hostUI.DebugBackgroundColor = 'DarkCyan'
30+
$hostUI.VerboseBackgroundColor = 'DarkBlue'
31+
$hostUI.VerboseForegroundColor = 'Cyan'
32+
33+
$consoleStatusCheck = $null
34+
$consoleStatusCheck = Get-ConsoleStatus
35+
36+
Write-Host ' '
37+
Write-Host 'ComputerName: ' -NoNewline ; Write-Host " $($consoleStatusCheck.ComputerName)" -ForegroundColor Green
38+
Write-Host 'User: ' -NoNewline ; Write-Host " $($consoleStatusCheck.User)" -ForegroundColor Green
39+
Write-Host 'IsAdmin: ' -NoNewline ; Write-Host " $($consoleStatusCheck.IsAdmin)" -ForegroundColor Green
40+
Write-Host 'PSVersion: ' -NoNewline ; Write-Host " $($consoleStatusCheck.PSVersion)" -ForegroundColor Green
41+
Write-Host 'PSEdition: ' -NoNewline ; Write-Host " $($consoleStatusCheck.PSEdition)" -ForegroundColor Green
42+
Write-Host ' '
43+
Write-Host ' '
44+
45+
Start-PowerCLI

vester-ws-nano/PSEnv.Functions.ps1

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<#
2+
.SYNOPSIS
3+
PowerShell Environment Functions File
4+
.DESCRIPTION
5+
This configuration file is used to store functions that are read in by a PowerShell profile
6+
7+
Check for the presense of a PSEnv.Config.ps1 module file which might call this file
8+
.NOTES
9+
Version: 1.0.0
10+
#>
11+
12+
[cmdletbinding()]
13+
param()
14+
15+
function Get-ConsoleStatus {
16+
17+
PROCESS {
18+
19+
# check to see if running as Admin and then setup the the custom PS console window title to include some good info
20+
[bool]$runAsAdminCheck = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
21+
[System.String]$psVersionCheck = $psversiontable.PSVersion.ToString()
22+
23+
[string]$userName = $null
24+
$userName = "$ENV:USERDOMAIN" + '\' + "$ENV:USERNAME"
25+
26+
$psEditonCheck = $null
27+
if ($psVersionTable.PSEdition) {
28+
$psEditonCheck = $psVersionTable.PSEdition
29+
}
30+
31+
[PSCustomObject] @{
32+
ComputerName = $Env:ComputerName
33+
User = $userName
34+
IsAdmin = $runAsAdminCheck
35+
PSVersion = $psVersionCheck
36+
PSEdition = $psEditonCheck
37+
}
38+
39+
} # end PROCESS block
40+
41+
} # end function Get-ConsoleStatus
42+
43+
function Start-PowerCLI {
44+
45+
Get-module -ListAvailable PowerCLI* | Import-module
46+
47+
$productName = "vSphere PowerCLI"
48+
$productShortName = "PowerCLI"
49+
$version = Get-PowerCLIVersion
50+
$windowTitle = "VMware $productName {0}.{1}" -f $version.Major, $version.Minor
51+
$host.ui.RawUI.WindowTitle = "$windowTitle"
52+
# These did not exist and threw errors on docker build
53+
#$CustomInitScriptName = "Initialize-PowerCLIEnvironment_Custom.ps1"
54+
#$currentDir = Split-Path $MyInvocation.MyCommand.Path
55+
#$CustomInitScript = Join-Path $currentDir $CustomInitScriptName
56+
57+
#returns the version of Powershell
58+
# Note: When using, make sure to surround Get-PSVersion with parentheses to force value comparison
59+
function Get-PSVersion {
60+
if (test-path variable:psversiontable) {
61+
$psversiontable.psversion
62+
} else {
63+
[version]"1.0.0.0"
64+
}
65+
}
66+
67+
# Update PowerCLI version after snap-in load
68+
$version = Get-PowerCLIVersion
69+
$windowTitle = "VMware $productName {0}.{1} Release 1" -f $version.Major, $version.Minor
70+
$host.ui.RawUI.WindowTitle = "$windowTitle"
71+
72+
73+
# Launch text
74+
write-host " Welcome to VMware $productName!"
75+
write-host ""
76+
write-host "Log in to a vCenter Server or ESX host: " -NoNewLine
77+
write-host "Connect-VIServer" -foregroundcolor yellow
78+
write-host "To find out what commands are available, type: " -NoNewLine
79+
write-host "Get-VICommand" -foregroundcolor yellow
80+
write-host "Once you've connected, display all virtual machines: " -NoNewLine
81+
write-host "Get-VM" -foregroundcolor yellow
82+
write-host ""
83+
write-host " Copyright (C) VMware, Inc. All rights reserved."
84+
write-host ""
85+
write-host ""
86+
87+
# Modify the prompt function to change the console prompt.
88+
# Save the previous function, to allow restoring it back.
89+
# THERE IS A POWERSHELL ISSUE WITH THIS AT THE MOMENT
90+
#$originalPromptFunction = $function:prompt
91+
#function global:prompt{
92+
93+
# change prompt text
94+
# Write-Host "$productShortName " -NoNewLine -foregroundcolor Green
95+
# Write-Host ((Get-location).Path + ">") -NoNewLine
96+
# return " "
97+
#}
98+
99+
} # end function Start-PowerCLI
100+
101+
function Get-Environment {
102+
103+
[CmdletBinding()]
104+
param(
105+
[parameter(Position = 0)]
106+
[System.String[]]
107+
$moduleList = @(
108+
'PowerCLI*',
109+
'PowervRA',
110+
'PowervRO',
111+
'Vester',
112+
'Pester'
113+
)
114+
)
115+
116+
PROCESS {
117+
118+
Get-Module -Name $moduleList -ListAvailable | Select-Object Name, Version, CompanyName, Description | Format-Table -AutoSize
119+
120+
}
121+
122+
} # end function Get-Environment
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@{
2+
# Use Severity when you want to limit the generated diagnostic records to a
3+
# subset of: Error, Warning and Information.
4+
# Uncomment the following line if you only want Errors and Warnings but
5+
# not Information diagnostic records.
6+
Severity = @('Error', 'Warning')
7+
8+
# Use IncludeRules when you want to run only a subset of the default rule set.
9+
IncludeRules = @('PSAvoidDefaultValueSwitchParameter',
10+
'PSMissingModuleManifestField',
11+
'PSReservedCmdletChar',
12+
'PSReservedParams',
13+
'PSShouldProcess',
14+
'PSUseApprovedVerbs',
15+
'PSUseDeclaredVarsMoreThanAssigments',
16+
'PSUseCompatibleCmdlets')
17+
18+
# Use ExcludeRules when you want to run most of the default set of rules except
19+
# for a few rules you wish to "exclude". Note: if a rule is in both IncludeRules
20+
# and ExcludeRules, the rule will be excluded.
21+
#ExcludeRules = @('PSAvoidUsingWriteHost', 'PSAvoidGlobalVars')
22+
23+
# You can use the following entry to supply parameters to rules that take parameters.
24+
# For instance, the PSAvoidUsingCmdletAliases rule takes a whitelist for aliases you
25+
# want to allow.
26+
Rules = @{
27+
# Do not flag 'cd' alias.
28+
# PSAvoidUsingCmdletAliases = @{Whitelist = @('cd')}
29+
30+
# Check if your script uses cmdlets that are compatible on PowerShell Core, version 6.0.0-alpha, on Linux.
31+
PSUseCompatibleCmdlets = @{
32+
Compatibility = @(
33+
"core-6.0.0-alpha-linux",
34+
"core-6.0.0-alpha-osx",
35+
"core-6.0.0-alpha-windows"
36+
#"desktop-5.1.14393.206-windows"
37+
)
38+
}
39+
}
40+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<ComponentDescriptor>
2+
<Name>VMware.VimAutomation.Cis.Core.Commands</Name>
3+
<Assembly>VMware.VimAutomation.Cis.Core.Commands</Assembly>
4+
<ImplementingType>VMware.VimAutomation.Cis.Core.Commands.CisCommandsComponentImpl</ImplementingType>
5+
<IsSnapin>true</IsSnapin>
6+
<ProvidedServiceList>
7+
</ProvidedServiceList>
8+
<RequiredServiceList>
9+
<ServiceDescriptor>
10+
<Name>CisCoreService</Name>
11+
<Version>1.0</Version>
12+
</ServiceDescriptor>
13+
</RequiredServiceList>
14+
<ExtendedServiceList>
15+
</ExtendedServiceList>
16+
<Version>
17+
<Major>5</Major>
18+
<Minor>1</Minor>
19+
<Revision>0</Revision>
20+
<Build>5327113</Build>
21+
<Company>VMware Inc.</Company>
22+
<Copyright>Copyright 2014</Copyright>
23+
<UserFriendlyVersion>VMware VDS PowerCLI Component 5.1 build 5327113</UserFriendlyVersion>
24+
<Description>Provides core cmdlets for managing VMware Cloud Infrastructure Suite.</Description>
25+
</Version>
26+
</ComponentDescriptor>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<ComponentDescriptor>
2+
<Name>VMware.VimAutomation.Cis.Core</Name>
3+
<Assembly>VMware.VimAutomation.Cis.Core.Impl</Assembly>
4+
<ImplementingType>VMware.VimAutomation.Cis.Core.Impl.V1.CisComponentImpl</ImplementingType>
5+
<IsSnapin>false</IsSnapin>
6+
7+
<ProvidedServiceList>
8+
<ServiceDescriptor>
9+
<Name>CisCoreService</Name>
10+
<Version>1.0</Version>
11+
</ServiceDescriptor>
12+
</ProvidedServiceList>
13+
14+
<RequiredServiceList>
15+
</RequiredServiceList>
16+
17+
<ExtendedServiceList></ExtendedServiceList>
18+
</ComponentDescriptor>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function global:Get-CisCommand([string] $Name = "*") {
2+
get-command -module PowerCLI.Cis -Name $Name
3+
}
4+
5+
# Set any aliases here...
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)