onpremcloudguy / psnewcmenv Goto Github PK
View Code? Open in Web Editor NEWPowerShell script to create SCCM environment.
PowerShell script to create SCCM environment.
Need to update New-SCCMServer to use the latest ADK with separate WinPE.
ADK
$SetupSwitches = "/Features OptionId.DeploymentTools OptionId.ImagingAndConfigurationDesigner OptionId.ICDConfigurationDesigner OptionId.UserStateMigrationTool /norestart /quiet /ceip off"
Start-Process -FilePath "$($path)\adksetup.exe" -ArgumentList $SetupSwitches -NoNewWindow -Wait
PE
$SetupSwitches = "/Features OptionId.WindowsPreinstallationEnvironment /norestart /quiet /ceip off"
Start-Process -FilePath "$($path)\adkwinpesetup.exe" -ArgumentList $SetupSwitches -NoNewWindow -Wait
Restart-Computer -Force
Looks like there's a pre-req to have a Virtual Switch named Internet
before starting, otherwise we're left indefinitely waiting on line 76 in newRRASServer.ps1
because it can't connect.
I'll submit a PR for some error handling.
For file NewSCCMServer.PS1 - if there are more than one update, the InitiateUpgrade method doesn't work.
Hey, this looks awesome and I can't wait to start using it.
The Convert-WindowsImage
module uses Dismount-DiskImage
with the -PassThru
parameter. The Dismount-DiskImage
cmdlet has changed behaviour in 1809 onwards where the -PassThru
parameter doesn't exist. Microsoft docs are yet to be updated on this, I've left feedback.
As a result a lot goes wrong. I know it's out of your hands but I'm just sharing this as an FYI. The Convert-WindowsImage
module hasn't been updated for a while, I'm not sure if it will get fixed. Regardless I created an issue in the repo where the module lives and on the doc page for the Dismount-DiskImage
function.
Maybe for your own interest, the below is what's printed to console in this scenario (note I also have a Pester issue where -Show
doesn't exist, but I'll check that out tomorrow..):
[acc@DESKTOP-PFFNJ90] [20:44:01] PS C:\VMs\PSNewCMENV
> .\LabTest.ps1
Invoke-Pester : A parameter cannot be found that matches parameter name 'Show'.
At C:\VMs\PSNewCMENV\NewENV.ps1:36 char:68
+ ... HDX = Invoke-Pester -TestName "Reference-VHDX" -PassThru -Show Passed
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Pester], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Invoke-Pester
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\acc\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): a
Dismount-DiskImage : A parameter cannot be found that matches parameter name 'PassThru'.
At C:\Program Files\WindowsPowerShell\Modules\Convert-Windowsimage\10.0\Convert-WindowsImage.psm1:2401 char:77
+ ... $DismountDiskImage = Dismount-DiskImage -ImagePath $IsoPath -PassThru
+ ~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Dismount-DiskImage], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Dismount-DiskImage
Invoke-Pester : A parameter cannot be found that matches parameter name 'Show'.
At C:\VMs\PSNewCMENV\NewENV.ps1:51 char:61
+ ... $TNetwork = Invoke-Pester -TestName "vSwitch" -PassThru -Show None
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Pester], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Invoke-Pester
Invoke-Pester : A parameter cannot be found that matches parameter name 'show'.
At C:\VMs\PSNewCMENV\newRRASServer.ps1:48 char:52
+ if (((Invoke-Pester -TestName "RRAS" -PassThru -show None).TestRe ...
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Pester], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Invoke-Pester
Get-VMNetworkAdapter : Hyper-V was unable to find a virtual machine with name "RRAS".
At C:\VMs\PSNewCMENV\newRRASServer.ps1:110 char:10
+ if ((Get-VMNetworkAdapter -VMName $RRASConfig.name | Where-Object ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (:) [Get-VMNetworkAdapter], VirtualizationException
+ FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.GetVMNetworkAdapter
Invoke-Pester : A parameter cannot be found that matches parameter name 'show'.
At C:\VMs\PSNewCMENV\newRRASServer.ps1:111 char:56
+ if (((Invoke-Pester -TestName "RRAS" -PassThru -show None).Te ...
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Pester], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Invoke-Pester
Invoke-Command : Cannot validate argument on parameter 'Session'. The argument is null or empty. Provide an argument
that is not null or empty, and then try the command again.
At C:\VMs\PSNewCMENV\newRRASServer.ps1:132 char:33
+ Invoke-Command -Session $RRASConfigSession -ScriptBlock { Set ...
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand
Invoke-Command : Cannot validate argument on parameter 'Session'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
At C:\VMs\PSNewCMENV\newRRASServer.ps1:134 char:33
+ Invoke-Command -Session $RRASConfigSession -ScriptBlock { Set ...
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand
Remove-PSSession : Cannot bind argument to parameter 'Session' because it is null.
At C:\VMs\PSNewCMENV\newRRASServer.ps1:135 char:30
+ $RRASConfigSession | Remove-PSSession
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Remove-PSSession], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.RemovePSSe ssionCommand
Describing RRAS
[-] RRAS VHDX Should exist 576ms
Expected: {True}
But was: {False}
38: it 'RRAS VHDX Should exist' { $tRRASVHDXExists | should be $true }
at <ScriptBlock>, C:\VMs\PSNewCMENV\NewENV.Tests.ps1: line 38
[-] RRAS Server Should exist 133ms
Expected: {1}
But was: {0}
39: it 'RRAS Server Should exist' { $tRRASExist | should be 1 }
at <ScriptBlock>, C:\VMs\PSNewCMENV\NewENV.Tests.ps1: line 39
[-] RRAS Server is Running 20ms
Expected: {1}
But was: {0}
40: it 'RRAS Server is Running' { $trrasrunning | should be 1 }
at <ScriptBlock>, C:\VMs\PSNewCMENV\NewENV.Tests.ps1: line 40
[!] RRAS Routing Installed 7ms
[!] RRAS External NIC Renamed 3ms
[!] RRAS Lab NIC Renamed 2ms
[!] RRAS Lab IP Address Set 1ms
[!] RRAS VPN enabled 1ms
[!] RRAS has access to Internet 1ms
Tests completed in 749ms
Passed: 0 Failed: 3 Skipped: 6 Pending: 0 Inconclusive: 0
Invoke-Pester : A parameter cannot be found that matches parameter name 'show'.
At C:\VMs\PSNewCMENV\newDCServer.ps1:63 char:51
+ if (!((Invoke-Pester -TestName "DC" -PassThru -show None).TestRes ...
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Pester], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Invoke-Pester
Describing DC
[-] DC VHDX Should Exist 75ms
Expected: {True}
But was: {False}
68: it 'DC VHDX Should Exist' { $TDCVHDXExists | should be $true }
at <ScriptBlock>, C:\VMs\PSNewCMENV\NewENV.Tests.ps1: line 68
[-] DC Should Exist 18ms
Expected: {1}
But was: {0}
69: it "DC Should Exist" { $TDCExists | should be 1 }
at <ScriptBlock>, C:\VMs\PSNewCMENV\NewENV.Tests.ps1: line 69
[-] DC Should be running 21ms
Expected: {1}
But was: {0}
70: it "DC Should be running" { $TDCRunning | should be 1 }
at <ScriptBlock>, C:\VMs\PSNewCMENV\NewENV.Tests.ps1: line 70
[!] DC IP Address 8ms
[!] DC has access to Internet 1ms
[!] DC Domain Services Installed 1ms
[!] DC Promoted 2ms
[!] DC DHCP Scope Active 2ms
[!] DC SCCM Servers Group 2ms
Tests completed in 135ms
Passed: 0 Failed: 3 Skipped: 6 Pending: 0 Inconclusive: 0
Invoke-Pester : A parameter cannot be found that matches parameter name 'show'.
At C:\VMs\PSNewCMENV\NewCAServer.PS1:63 char:50
+ if (((Invoke-Pester -TestName "CA" -PassThru -show None).TestResu ...
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Pester], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Invoke-Pester
Invoke-Pester : A parameter cannot be found that matches parameter name 'show'.
At C:\VMs\PSNewCMENV\NewSCCMServer.PS1:122 char:63
+ ... (((Invoke-Pester -tag $cmConfig.CMServerType -PassThru -show None).T ...
+ ~~~~~
+ CategoryInfo : InvalidArgument: (:) [Invoke-Pester], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Invoke-Pester
Describing CM
[-] CM VHDX Should Exist 120ms
Expected: {True}
But was: {False}
192: it 'CM VHDX Should Exist' { $TCMVHDXExists | should be $true }
at <ScriptBlock>, C:\VMs\PSNewCMENV\NewENV.Tests.ps1: line 192
[-] CM Should Exist 18ms
Expected: {1}
But was: {0}
193: it 'CM Should Exist' { $TCMExists | should be 1 }
at <ScriptBlock>, C:\VMs\PSNewCMENV\NewENV.Tests.ps1: line 193
[-] CM Should be running 20ms
But was: {0}
194: it 'CM Should be running' { $TCMRunning | should be 1 }
at <ScriptBlock>, C:\VMs\PSNewCMENV\NewENV.Tests.ps1: line 194
[!] CM IP Address 7ms
[!] CM has access to Internet 1ms
[!] CM has access to MMS.lab 1ms
[!] CM .Net Feature installed 1ms
[!] CM Features are installed 2ms
[!] CM SQL Instance is installed 4ms
[!] CM ADK Installed 2ms
[!] CM Server in Group 1ms
[!] CM SCCM Installed 1ms
[!] CM SCCM Console Installed 1ms
[!] CM Site Boundary added 1ms
[!] CM System Discovery enabled 1ms
Tests completed in 189ms
Passed: 0 Failed: 3 Skipped: 12 Pending: 0 Inconclusive: 0
CM Server Completed: 11/28/2019 20:50:04
I found RRAS server config would never get passed line 77 in new-RRASServer if I changed the AdmPwd to be anything other than P@ssw0rd. At least this was true while trying to test with env "MMS". Will troubleshoot more and submit PR.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.