< Back

Bootstrap-PowerShellCore

Sun Jan 12, 2020 6:07 pm

NAME Bootstrap-PowerShellCore



SYNOPSIS

Use PowerShell to Update PowerShell Core. If you're on Windows, this function can be used to do the initial

install of PowerShell Core. On any other OS, a version of PowerShell Core (at least 6.0.0-beta) must already

be installed and used to run this function.





SYNTAX

Bootstrap-PowerShellCore [-RemoteOSGuess <String>] -RemoteHostNameOrIP <String> -LocalUserName <String>

[-LocalPasswordSS <SecureString>] [-KeyFilePath <String>] [-OS <String>] [-UsePackageManagement]

[-ConfigurePSRemoting] [<CommonParameters>]



Bootstrap-PowerShellCore [-RemoteOSGuess <String>] -RemoteHostNameOrIP <String> -DomainUserName <String>

[-DomainPasswordSS <SecureString>] [-KeyFilePath <String>] [-OS <String>] [-UsePackageManagement]

[-ConfigurePSRemoting] [<CommonParameters>]





DESCRIPTION

See SYNOPSIS





PARAMETERS

-RemoteOSGuess <String>

This parameter is OPTIONAL.



This parameter takes a string (either "Windows" or "Linux") that represents the type of platform you

anticipate the

Remote Host is running. The default value for this parameter is "Windows".



IMPORTANT NOTE: If you specify "Linux" and it turns out that the Remote Host is running Windows, this function

will fail.

So, if you're not sure, leave the default value "Windows".



Required? false

Position? named

Default value Windows

Accept pipeline input? false

Accept wildcard characters? false



-RemoteHostNameOrIP <String>

This parameter is MANDATORY.



This parameter takes a string that represents the DNS-resolvable HostName/FQDN or IPv4 Address of the target

Remote Host



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-LocalUserName <String>

This parameter is MANDATORY for the Parameter Set 'Local'.



This parameter takes a string that represents the Local User Account on the Remote Host that you are using to

ssh into

the Remote Host. This string must be in format: <RemoteHostName>\\<UserName>



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-DomainUserName <String>

This parameter is MANDATORY for the Parameter Set 'Domain'.



This parameter takes a string that represents the Domain User Account on the Remote Host that you are using to

ssh into

the Remote Host. This string must be in format: <DomainShortName>\\<UserName>



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-LocalPasswordSS <SecureString>

This parameter is OPTIONAL. (However, either -LocalPasswordSS or -KeyFilePath is mandatory for the 'Domain'

Parameter Set)



This parameter takes a securestring that represents the password for the -LocalUserName you are using to ssh

into the

Remote Host.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-DomainPasswordSS <SecureString>

This parameter is OPTIONAL. (However, either -DomainPasswordSS or -KeyFilePath is mandatory for the 'Domain'

Parameter Set)



This parameter takes a securestring that represents the password for the -DomainUserName you are using to ssh

into the

Remote Host.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-KeyFilePath <String>

This parameter is OPTIONAL. (However, either -DomainPasswordSS, -LocalPasswordSS, or -KeyFilePath is required)



This parameter takes a string that represents the full path to the Key File you are using to ssh into the

Remote Host.

Use this parameter instead of -LocalPasswordSS or -DomainPasswordSS.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-OS <String>

This parameter is OPTIONAL.



By default, this function probes the Remote Host to determine the OS running on the Remote Host. If you know

in advance

the OS running on the Remote Host, or if the Get-SSHProbe function returns incorrect information, use this

parameter

to specify one of the following values:

"Ubuntu1404","Ubuntu1604","Ubuntu1804","Ubuntu1810","Debian8","Debian9","CentOS7","RHEL7","OpenSUSE423","Fe

dora","Raspbian"



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-UsePackageManagement [<SwitchParameter>]

This parameter is OPTIONAL, however, it has a default value of $True



This parameter is a switch. If used (default behavior), the appropriate Package Management system on the

Remote Host

will be used to install PowerShell Core.



If explicitly set to $False, the appropriate PowerShell Core installation package will be downloaded directly

from GitHub

and installed on the Remote Host.



Required? false

Position? named

Default value True

Accept pipeline input? false

Accept wildcard characters? false



-ConfigurePSRemoting [<SwitchParameter>]

This parameter is OPTIONAL.



This parameter is a switch. If used, in addition to installing PowerShell Core, sshd_config will be modified

in order to enable

PSRemoting using PowerShell Core.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\># Minimal parameters...



$BootstrapPwshSplatParams = @{

RemoteHostNameOrIP = "zerowin16sshb"

DomainUserNameSS = "zero\\zeroadmin"

DomainPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)

}

Bootstrap-PowerShellCore @BootstrapPwshSplatParams









-------------------------- EXAMPLE 2 --------------------------



PS C:\\># Install pwsh AND configure sshd_config for PSRemoting...



$BootstrapPwshSplatParams = @{

RemoteHostNameOrIP = "centos7nodomain"

LocalUserNameSS = "centos7nodomain\\vagrant"

LocalPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)

ConfigurePSRemoting = $True

}

Bootstrap-PowerShellCore @BootstrapPwshSplatParams









-------------------------- EXAMPLE 3 --------------------------



PS C:\\># Instead of using the Remote Host's Package Management System (which is default behavior),



# download and install the appropriate pwsh package directly from GitHub



$BootstrapPwshSplatParams = @{

RemoteHostNameOrIP = "centos7nodomain"

LocalUserNameSS = "centos7nodomain\\vagrant"

LocalPasswordSS = $(Read-Host -Prompt "Enter password" -AsSecureString)

UsePackageManagement = $False

}

Bootstrap-PowerShellCore @BootstrapPwshSplatParams











RELATED LINKS