Service | Microsoft Docs article | Related commit history on GitHub | Change details |
---|---|---|---|
Microsoft.PowerShell.Core | Enter Pssession (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Core/Enter-PSSession.md | external help file: System.Management.Automation.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Core Previously updated : 07/23/2020 Last updated : 01/24/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/enter-pssession?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Enter-PSSession Enter-PSSession [-ComputerName] <String> [-EnableNetworkAccess] [[-Credential] < ### SSHHost ```-Enter-PSSession [-HostName] <String> [-Port <Int32>] [-UserName <String>] [-KeyFilePath <String>] - [-SSHTransport] [-ConnectingTimeout <int>] [<CommonParameters>] +Enter-PSSession [-HostName] <String> [-Options <Hashtable>] [-Port <Int32>] [-UserName <String>] + [-KeyFilePath <String>] [-Subsystem <String>] [-ConnectingTimeout <Int32>] [-SSHTransport] + [<CommonParameters>] ``` ### Session Otherwise you will have to use SSH key based user authentication. ### Example 7: Start an interactive session using SSH and specify the Port and user authentication key ```powershell-PS> Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath c:\<path>\userAKey_rsa +PS> Enter-PSSession -HostName UserA@LinuxServer02:22 -KeyFilePath c:\sshkeys\userAKey_rsa ``` This example shows how to start an interactive session using SSH. It uses the **Port** parameter to specify the port to use and the **KeyFilePath** parameter to specify an RSA key used to authenticate the user on the remote computer. +### Example 8: Start an interactive session using SSH options ++```powershell +$options = @{ + Port=22 + User = 'UserA' + Host = 'LinuxServer02' +} +Enter-PSSession -KeyFilePath c:\sshkeys\userAKey_rsa -Options $options +``` ++This example shows how to start an interactive session using SSH. The **Options** parameter takes a +hashtable of values that are passed as options to the underlying `ssh` command the established the +connection to the remote system. + ## Parameters ### -AllowRedirection Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -Options ++Specifies a hashtable of SSH options used when connecting to a remote SSH-based session. The +possible options are any values supported by the Unix-based version of the +[ssh](https://man.openbsd.org/ssh#o) command. ++Any values explicitly passed by parameters take precedence over values passed in the **Options** +hashtable. For example, using the **Port** parameter overrides any `Port` key-value pair passed in +the **Options** hashtable. ++```yaml +Type: System.Collections.Hashtable +Parameter Sets: SSHHost +Aliases: ++Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Port Specifies the network port on the remote computer that is used for this command. Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Accepted values: true Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: powershell +Default value: Powershell Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` is available. To cancel the `Enter-PSSession` command, press <kbd>CTRL</kbd>+<kb The **HostName** parameter set was included starting with PowerShell 6.0. It was added to provide PowerShell remoting based on Secure Shell (SSH). Both SSH and PowerShell are supported on multiple-platforms (Windows, Linux, macOS) and PowerShell remoting will work over these platforms where +platforms (Windows, Linux, macOS) and PowerShell remoting works over these platforms where PowerShell and SSH are installed and configured. This is separate from the previous Windows only remoting that is based on WinRM and much of the WinRM specific features and limitations do not apply. For example, WinRM based quotas, session options, custom endpoint configuration, and Prior to PowerShell 7.1, remoting over SSH did not support second-hop remote ses capability was limited to sessions using WinRM. PowerShell 7.1 allows `Enter-PSSession` and `Enter-PSHostProcess` to work from within any interactive remote session. +The `ssh` executable obtains configuration data from the following sources in the following order: ++1. command-line options +1. user's configuration file (~/.ssh/config) +1. system-wide configuration file (/etc/ssh/ssh_config) ++The following cmdlet parameters get mapped into `ssh` parameters and options: ++| Cmdlet parameter | ssh parameter | equivalent ssh -o option | +| -------------------------- | ------------------------------- | ------------------------------- | +| `-KeyFilePath` | `-i <KeyFilePath>` | `-o IdentityFile=<KeyFilePath>` | +| `-UserName` | `-l <UserName>` | `-o User=<UserName>` | +| `-Port` | `-p <Port>` | `-o Port=<Port>` | +| `-ComputerName -Subsystem` | `-s <ComputerName> <Subsystem>` | `-o Host=<ComputerName>` | ++Any values explicitly passed by parameters take precedence over values passed in the **Options** +hashtable. For more information about `ssh_config` files, see +[ssh_config(5)](https://man.openbsd.org/ssh_config.5). +++ ## Related links [Exit-PSSession](Exit-PSSession.md) |
Microsoft.PowerShell.Core | Invoke Command (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Core/Invoke-Command.md | Invoke-Command -Credential <PSCredential> [-ConfigurationName <String>] [-Thrott ``` Invoke-Command [-Port <Int32>] [-AsJob] [-HideComputerName] [-JobName <String>] [-ScriptBlock] <ScriptBlock> -HostName <String[]> [-UserName <String>] [-KeyFilePath <String>]- [-SSHTransport] [-RemoteDebug] [-InputObject <PSObject>] [-ArgumentList <Object[]>] - [-Subsystem <String>] [-ConnectingTimeout <int>] [<CommonParameters>] + [-Subsystem <String>] [-ConnectingTimeout <Int32>] [-SSHTransport] [-Options <Hashtable>] + [-RemoteDebug] [-InputObject <PSObject>] [-ArgumentList <Object[]>] [<CommonParameters>] ``` ### ContainerId Invoke-Command [-AsJob] [-HideComputerName] [-JobName <String>] [-ScriptBlock] < ### FilePathSSHHost ```-Invoke-Command [-AsJob] [-HideComputerName] -FilePath <String> -HostName <String[]> - [-UserName <String>] [-KeyFilePath <String>] [-SSHTransport] [-RemoteDebug] - [-InputObject <PSObject>] [-ArgumentList <Object[]>] [<CommonParameters>] +Invoke-Command [-AsJob] [-HideComputerName] [-FilePath] <String> -HostName <String[]> + [-UserName <String>] [-KeyFilePath <String>] [-Subsystem <String>] [-ConnectingTimeout <Int32>] + [-SSHTransport] [-Options <Hashtable>] [-RemoteDebug] [-InputObject <PSObject>] + [-ArgumentList <Object[]>] [<CommonParameters>] ``` ### FilePathSSHHostHash ```-Invoke-Command [-AsJob] [-HideComputerName] -FilePath <String> -SSHConnection <Hashtable[]> +Invoke-Command [-AsJob] [-HideComputerName] [-FilePath] <String> -SSHConnection <Hashtable[]> [-RemoteDebug] [-InputObject <PSObject>] [-ArgumentList <Object[]>] [<CommonParameters>] ``` $sshConnections = $results = Invoke-Command -FilePath c:\Scripts\CollectEvents.ps1 -SSHConnection $sshConnections ``` +### Example 22: Connect to a remote SSH session using SSH options ++This example shows how to run a script file on a remote Linux-based machine using SSH options. The +**Options** parameter takes a hashtable of values that are passed as options to the underlying `ssh` +command the established the connection to the remote system. ++```powershell +$options = @{ + Port=22 + User = 'UserB' + Host = 'LinuxServer5' +} +$results = Invoke-Command -FilePath c:\Scripts\CollectEvents.ps1 -KeyFilePath '/Users/UserB/id_rsa' -Options $options +``` + ## Parameters ### -AllowRedirection For more information about PowerShell background jobs, see [about_Jobs](About/ab ```yaml Type: System.Management.Automation.SwitchParameter-Parameter Sets: FilePathRunspace, Session, ComputerName, FilePathComputerName, Uri, FilePathUri, VMId, VMName, FilePathVMId, FilePathVMName, SSHHost, ContainerId, FilePathContainerId, SSHHostHashParam, FilePathSSHHost, FilePathSSHHostHash +Parameter Sets: Session, FilePathRunspace, ComputerName, FilePathComputerName, Uri, FilePathUri, VMId, VMName, FilePathVMId, FilePathVMName, SSHHost, ContainerId, FilePathContainerId, SSHHostHashParam, FilePathSSHHost, FilePathSSHHostHash Aliases: Required: False This parameter was introduced in PowerShell 7.2 ```yaml Type: System.Int32-Parameter Sets: SSHHost +Parameter Sets: SSHHost, FilePathSSHHost Aliases: Required: False Position: Named-Default value: unlimited +Default value: Unlimited Accept pipeline input: False Accept wildcard characters: False ``` This parameter affects only the output display. It doesn't change the object. ```yaml Type: System.Management.Automation.SwitchParameter-Parameter Sets: FilePathRunspace, Session, ComputerName, FilePathComputerName, Uri, FilePathUri, VMId, VMName, FilePathVMId, FilePathVMName, SSHHost, ContainerId, FilePathContainerId, SSHHostHashParam, FilePathSSHHost, FilePathSSHHostHash +Parameter Sets: Session, FilePathRunspace, ComputerName, FilePathComputerName, Uri, FilePathUri, VMId, VMName, FilePathVMId, FilePathVMName, SSHHost, ContainerId, FilePathContainerId, SSHHostHashParam, FilePathSSHHost, FilePathSSHHostHash Aliases: HCN Required: False Accept pipeline input: False Accept wildcard characters: False ``` +### -Options ++Specifies a hashtable of SSH options used when connecting to a remote SSH-based session. The +possible options are any values supported by the Unix-based version of the +[ssh](https://man.openbsd.org/ssh#o) command. ++Any values explicitly passed by parameters take precedence over values passed in the **Options** +hashtable. For example, using the **Port** parameter overrides any `Port` key-value pair passed in +the **Options** hashtable. ++```yaml +Type: System.Collections.Hashtable +Parameter Sets: SSHHost, FilePathSSHHost +Aliases: ++Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Port Specifies the network port on the remote computer that is used for this command. To connect to a Used to run the invoked command in debug mode in the remote PowerShell session. ```yaml Type: System.Management.Automation.SwitchParameter-Parameter Sets: FilePathRunspace, Session, ComputerName, FilePathComputerName, Uri, FilePathUri, VMId, VMName, FilePathVMId, FilePathVMName, SSHHost, ContainerId, FilePathContainerId, SSHHostHashParam, FilePathSSHHost, FilePathSSHHostHash +Parameter Sets: Session, FilePathRunspace, ComputerName, FilePathComputerName, Uri, FilePathUri, VMId, VMName, FilePathVMId, FilePathVMName, SSHHost, ContainerId, FilePathContainerId, SSHHostHashParam, FilePathSSHHost, FilePathSSHHostHash Aliases: Required: False see [about_PSSessions](./About/about_PSSessions.md). ```yaml Type: System.Management.Automation.Runspaces.PSSession[]-Parameter Sets: FilePathRunspace, Session +Parameter Sets: Session, FilePathRunspace Aliases: Required: False If this parameter is not used, the default is the 'powershell' subsystem. ```yaml Type: System.String-Parameter Sets: SSHHost +Parameter Sets: SSHHost, FilePathSSHHost Aliases: Required: False Position: Named Default value: powershell-Accept pipeline input: True (ByPropertyName) +Accept pipeline input: False Accept wildcard characters: False ``` The throttle limit applies only to the current command, not to the session or to ```yaml Type: System.Int32-Parameter Sets: FilePathRunspace, Session, ComputerName, FilePathComputerName, Uri, FilePathUri, VMId, VMName, FilePathVMId, FilePathVMName, ContainerId, FilePathContainerId +Parameter Sets: Session, FilePathRunspace, ComputerName, FilePathComputerName, Uri, FilePathUri, VMId, VMName, FilePathVMId, FilePathVMName, ContainerId, FilePathContainerId Aliases: Required: False Accept wildcard characters: False This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,--WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).+-WarningAction, and -WarningVariable. For more information, see +[about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216). ## Inputs disconnect/reconnect features are currently not supported. For more information PowerShell SSH remoting, see [PowerShell Remoting Over SSH](/powershell/scripting/learn/remoting/ssh-remoting-in-powershell-core). +The `ssh` executable obtains configuration data from the following sources in the following order: ++1. command-line options +1. user's configuration file (~/.ssh/config) +1. system-wide configuration file (/etc/ssh/ssh_config) ++The following cmdlet parameters get mapped into `ssh` parameters and options: ++| Cmdlet parameter | ssh parameter | equivalent ssh -o option | +| -------------------------- | ------------------------------- | ------------------------------- | +| `-KeyFilePath` | `-i <KeyFilePath>` | `-o IdentityFile=<KeyFilePath>` | +| `-UserName` | `-l <UserName>` | `-o User=<UserName>` | +| `-Port` | `-p <Port>` | `-o Port=<Port>` | +| `-ComputerName -Subsystem` | `-s <ComputerName> <Subsystem>` | `-o Host=<ComputerName>` | ++Any values explicitly passed by parameters take precedence over values passed in the **Options** +hashtable. For more information about `ssh_config` files, see +[ssh_config(5)](https://man.openbsd.org/ssh_config.5). + ## Related links [about_PSSessions](./About/about_PSSessions.md) |
Microsoft.PowerShell.Core | New Pssession (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Core/New-PSSession.md | external help file: System.Management.Automation.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Core Previously updated : 07/27/2021 Last updated : 01/24/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/new-pssession?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 Title: New-PSSession New-PSSession [-Name <String[]>] [-ConfigurationName <String>] -ContainerId <Str ### UseWindowsPowerShellParameterSet ```-New-PSSession -UseWindowsPowerShell [-Name <string[]>] [<CommonParameters>] +New-PSSession [-Name <String[]>] [-UseWindowsPowerShell] [<CommonParameters>] ``` ### SSHHost ``` New-PSSession [-Name <String[]>] [-Port <Int32>] [-HostName] <String[]> [-UserName <String>]- [-KeyFilePath <String>] [-SSHTransport] [-Subsystem <String>] [-ConnectingTimeout <int>] - [<CommonParameters>] + [-KeyFilePath <String>] [-Subsystem <String>] [-ConnectingTimeout <Int32>] [-SSHTransport] + [-Options <Hashtable>] [<CommonParameters>] ``` ### SSHHostHashParam This example shows how to create multiple sessions using Secure Shell (SSH) and contain connection information for each session. Note that this example requires that the target remote computers have SSH configured to support key based user authentication. +### Example 15: Create a new session using SSH options ++```powershell +$options = @{ + Port=22 + User = 'UserB' + Host = 'LinuxServer5' +} +New-PSSession -KeyFilePath '/Users/UserB/id_rsa' -Options $options +``` ++This example shows how to create a new SSH-based session a remote Linux-based machine using SSH +options. The **Options** parameter takes a hashtable of values that are passed as options to the +underlying `ssh` command the established the connection to the remote system. + ## Parameters ### -AllowRedirection Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Accept pipeline input: False Accept wildcard characters: False ``` +### -Options ++Specifies a hashtable of SSH options used when connecting to a remote SSH-based session. The +possible options are any values supported by the Unix-based version of the +[ssh](https://man.openbsd.org/ssh#o) command. ++Any values explicitly passed by parameters take precedence over values passed in the **Options** +hashtable. For example, using the **Port** parameter overrides any `Port` key-value pair passed in +the **Options** hashtable. ++```yaml +Type: System.Collections.Hashtable +Parameter Sets: SSHHost +Aliases: ++Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -Port Specifies the network port on the remote computer that is used for this connection. To connect to a Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Accepted values: true Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: True Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` You can pipe a string, URI, or session object to this cmdlet. ## Notes -- This cmdlet uses the PowerShell remoting infrastructure. To use this cmdlet, the local- computer and any remote computers must be configured for PowerShell remoting. For more - information, see [about_Remote_Requirements](About/about_Remote_Requirements.md). -- To create a **PSSession** on the local computer, start PowerShell with the Run as administrator- option. -- When you are finished with the **PSSession**, use the `Remove-PSSession` cmdlet to delete the- **PSSession** and release its resources. -- The **HostName** and **SSHConnection** parameter sets were included starting with PowerShell 6.0.- They were added to provide PowerShell remoting based on Secure Shell (SSH). Both SSH and - PowerShell are supported on multiple platforms (Windows, Linux, macOS) and PowerShell remoting - will work over these platforms where PowerShell and SSH are installed and configured. This is - separate from the previous Windows only remoting that is based on WinRM and much of the WinRM - specific features and limitations do not apply. For example WinRM based quotas, session options, - custom endpoint configuration, and disconnect/reconnect features are currently not supported. For - more information about how to set up PowerShell SSH remoting, see - [PowerShell Remoting Over SSH](/powershell/scripting/learn/remoting/ssh-remoting-in-powershell-core). +This cmdlet uses the PowerShell remoting infrastructure. To use this cmdlet, the local computer and +any remote computers must be configured for PowerShell remoting. For more information, see +[about_Remote_Requirements](About/about_Remote_Requirements.md). ++To create a **PSSession** on the local computer, start PowerShell with the Run as administrator +option. ++When you are finished with the **PSSession**, use the `Remove-PSSession` cmdlet to delete the +**PSSession** and release its resources. ++The **HostName** and **SSHConnection** parameter sets were included starting with PowerShell 6.0. +They were added to provide PowerShell remoting based on Secure Shell (SSH). Both SSH and PowerShell +are supported on multiple platforms (Windows, Linux, macOS) and PowerShell remoting works over these +platforms where PowerShell and SSH are installed and configured. This is separate from the previous +Windows only remoting that is based on WinRM and much of the WinRM specific features and limitations +do not apply. For example WinRM based quotas, session options, custom endpoint configuration, and +disconnect/reconnect features are currently not supported. For more information about how to set up +PowerShell SSH remoting, see +[PowerShell Remoting Over SSH](/powershell/scripting/learn/remoting/ssh-remoting-in-powershell-core). ++The `ssh` executable obtains configuration data from the following sources in the following order: ++1. command-line options +1. user's configuration file (~/.ssh/config) +1. system-wide configuration file (/etc/ssh/ssh_config) ++The following cmdlet parameters get mapped into `ssh` parameters and options: ++| Cmdlet parameter | ssh parameter | equivalent ssh -o option | +| -------------------------- | ------------------------------- | ------------------------------- | +| `-KeyFilePath` | `-i <KeyFilePath>` | `-o IdentityFile=<KeyFilePath>` | +| `-UserName` | `-l <UserName>` | `-o User=<UserName>` | +| `-Port` | `-p <Port>` | `-o Port=<Port>` | +| `-ComputerName -Subsystem` | `-s <ComputerName> <Subsystem>` | `-o Host=<ComputerName>` | ++Any values explicitly passed by parameters take precedence over values passed in the **Options** +hashtable. For more information about `ssh_config` files, see +[ssh_config(5)](https://man.openbsd.org/ssh_config.5). ## Related links |
Microsoft.PowerShell.Utility | Invoke Restmethod (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Utility/Invoke-RestMethod.md | external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 05/27/2021 Last updated : 01/24/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Invoke-RestMethod Sends an HTTP or HTTPS request to a RESTful web service. ``` Invoke-RestMethod [-Method <WebRequestMethod>] [-FollowRelLink] [-MaximumFollowRelLink <Int32>] [-ResponseHeadersVariable <String>] [-StatusCodeVariable <String>] [-UseBasicParsing] [-Uri] <Uri>- [-WebSession <WebRequestSession>] [-SessionVariable <String>] [-AllowUnencryptedAuthentication] - [-Authentication <WebAuthenticationType>] [-Credential <PSCredential>] [-UseDefaultCredentials] - [-CertificateThumbprint <String>] [-Certificate <X509Certificate>] [-SkipCertificateCheck] - [-SslProtocol <WebSslProtocol>] [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] - [-TimeoutSec <Int32>] [-Headers <IDictionary>] [-MaximumRedirection <Int32>] - [-MaximumRetryCount <Int32>] [-RetryIntervalSec <Int32>] [-Proxy <Uri>] - [-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials] [-Body <Object>] - [-Form <IDictionary>] [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] - [-OutFile <String>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] - [-SkipHeaderValidation] [<CommonParameters>] + [-HttpVersion <Version>] [-WebSession <WebRequestSession>] [-SessionVariable <String>] + [-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>] + [-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>] + [-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>] + [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] [-TimeoutSec <Int32>] + [-Headers <IDictionary>] [-MaximumRedirection <Int32>] [-MaximumRetryCount <Int32>] + [-RetryIntervalSec <Int32>] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] + [-ProxyUseDefaultCredentials] [-Body <Object>] [-Form <IDictionary>] [-ContentType <String>] + [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] [-PassThru] [-Resume] + [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] [-SkipHeaderValidation] + [<CommonParameters>] ``` ### StandardMethodNoProxy Invoke-RestMethod [-Method <WebRequestMethod>] [-FollowRelLink] [-MaximumFollowR ``` Invoke-RestMethod [-Method <WebRequestMethod>] [-FollowRelLink] [-MaximumFollowRelLink <Int32>] [-ResponseHeadersVariable <String>] [-StatusCodeVariable <String>] [-UseBasicParsing] [-Uri] <Uri>- [-WebSession <WebRequestSession>] [-SessionVariable <String>] [-AllowUnencryptedAuthentication] - [-Authentication <WebAuthenticationType>] [-Credential <PSCredential>] [-UseDefaultCredentials] - [-CertificateThumbprint <String>] [-Certificate <X509Certificate>] [-SkipCertificateCheck] - [-SslProtocol <WebSslProtocol>] [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] - [-TimeoutSec <Int32>] [-Headers <IDictionary>] [-MaximumRedirection <Int32>] - [-MaximumRetryCount <Int32>] [-RetryIntervalSec <Int32>] -NoProxy [-Body <Object>] - [-Form <IDictionary>] [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] - [-OutFile <String>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] + [-HttpVersion <Version>] [-WebSession <WebRequestSession>] [-SessionVariable <String>] + [-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>] + [-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>] + [-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>] + [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] [-TimeoutSec <Int32>] + [-Headers <IDictionary>] [-MaximumRedirection <Int32>] [-MaximumRetryCount <Int32>] + [-RetryIntervalSec <Int32>] -NoProxy [-Body <Object>] [-Form <IDictionary>] + [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] + [-PassThru] [-Resume] [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] [-SkipHeaderValidation] [<CommonParameters>] ``` -### CustomMethodNoProxy +### CustomMethod ``` Invoke-RestMethod -CustomMethod <String> [-FollowRelLink] [-MaximumFollowRelLink <Int32>] [-ResponseHeadersVariable <String>] [-StatusCodeVariable <String>] [-UseBasicParsing] [-Uri] <Uri>- [-WebSession <WebRequestSession>] [-SessionVariable <String>] [-AllowUnencryptedAuthentication] - [-Authentication <WebAuthenticationType>] [-Credential <PSCredential>] [-UseDefaultCredentials] - [-CertificateThumbprint <String>] [-Certificate <X509Certificate>] [-SkipCertificateCheck] - [-SslProtocol <WebSslProtocol>] [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] - [-TimeoutSec <Int32>] [-Headers <IDictionary>] [-MaximumRedirection <Int32>] - [-MaximumRetryCount <Int32>] [-RetryIntervalSec <Int32>] -NoProxy [-Body <Object>] - [-Form <IDictionary>] [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] - [-OutFile <String>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] - [-SkipHeaderValidation] [<CommonParameters>] + [-HttpVersion <Version>] [-WebSession <WebRequestSession>] [-SessionVariable <String>] + [-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>] + [-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>] + [-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>] + [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] [-TimeoutSec <Int32>] + [-Headers <IDictionary>] [-MaximumRedirection <Int32>] [-MaximumRetryCount <Int32>] + [-RetryIntervalSec <Int32>] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] + [-ProxyUseDefaultCredentials] [-Body <Object>] [-Form <IDictionary>] [-ContentType <String>] + [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] [-PassThru] [-Resume] + [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] [-SkipHeaderValidation] + [<CommonParameters>] ``` -### CustomMethod +### CustomMethodNoProxy ``` Invoke-RestMethod -CustomMethod <String> [-FollowRelLink] [-MaximumFollowRelLink <Int32>] [-ResponseHeadersVariable <String>] [-StatusCodeVariable <String>] [-UseBasicParsing] [-Uri] <Uri>- [-WebSession <WebRequestSession>] [-SessionVariable <String>] [-AllowUnencryptedAuthentication] - [-Authentication <WebAuthenticationType>] [-Credential <PSCredential>] [-UseDefaultCredentials] - [-CertificateThumbprint <String>] [-Certificate <X509Certificate>] [-SkipCertificateCheck] - [-SslProtocol <WebSslProtocol>] [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] - [-TimeoutSec <Int32>] [-Headers <IDictionary>] [-MaximumRedirection <Int32>] - [-MaximumRetryCount <Int32>] [-RetryIntervalSec <Int32>] [-Proxy <Uri>] - [-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials] [-Body <Object>] - [-Form <IDictionary>] [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] - [-OutFile <String>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] + [-HttpVersion <Version>] [-WebSession <WebRequestSession>] [-SessionVariable <String>] + [-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>] + [-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>] + [-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>] + [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] [-TimeoutSec <Int32>] + [-Headers <IDictionary>] [-MaximumRedirection <Int32>] [-MaximumRetryCount <Int32>] + [-RetryIntervalSec <Int32>] -NoProxy [-Body <Object>] [-Form <IDictionary>] + [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] + [-PassThru] [-Resume] [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] [-SkipHeaderValidation] [<CommonParameters>] ``` + ## Description The `Invoke-RestMethod` cmdlet sends HTTP and HTTPS requests to Representational State Transfer $x 30 ``` +### Example 7: Send a request using HTTP 2.0 ++This example queries for GitHub issue using the HTTP 2.0 protocol. ++```powershell +$uri = 'https://api.github.com/repos/microsoftdocs/powershell-docs/issues' +Invoke-RestMethod -Uri $uri -HttpVersion 2.0 -SkipCertificateCheck +``` + ## Parameters ### -AllowUnencryptedAuthentication Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` This feature was added in PowerShell 6.0.0. ```yaml Type: System.String-Parameter Sets: CustomMethodNoProxy, CustomMethod +Parameter Sets: CustomMethod, CustomMethodNoProxy Aliases: CM Required: True Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: FL Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Accept pipeline input: False Accept wildcard characters: False ``` +### -HttpVersion ++Specifies the HTTP version used for the request. The default is `1.1`. ++Valid values are: ++- 1.0 +- 1.1 +- 2.0 +- 3.0 ++```yaml +Type: System.Version +Parameter Sets: (All) +Aliases: ++Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -InFile Gets the content of the web request from a file. Aliases: Required: True Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` |
Microsoft.PowerShell.Utility | Invoke Webrequest (7.3) | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.3/Microsoft.PowerShell.Utility/Invoke-WebRequest.md | external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility Previously updated : 08/02/2021 Last updated : 01/24/2022 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Invoke-WebRequest Gets content from a web page on the internet. ### StandardMethod (Default) ```-Invoke-WebRequest [-UseBasicParsing] [-Uri] <Uri> [-WebSession <WebRequestSession>] - [-SessionVariable <String>] [-AllowUnencryptedAuthentication] - [-Authentication <WebAuthenticationType>] [-Credential <PSCredential>] [-UseDefaultCredentials] - [-CertificateThumbprint <String>] [-Certificate <X509Certificate>] [-SkipCertificateCheck] - [-SslProtocol <WebSslProtocol>] [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] - [-TimeoutSec <Int32>] [-Headers <IDictionary>] [-MaximumRedirection <Int32>] - [-MaximumRetryCount <Int32>] [-RetryIntervalSec <Int32>] [-Method <WebRequestMethod>] - [-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials] [-Body <Object>] - [-Form <IDictionary>] [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] - [-OutFile <String>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] - [-SkipHeaderValidation] [<CommonParameters>] +Invoke-WebRequest [-UseBasicParsing] [-Uri] <Uri> [-HttpVersion <Version>] [-WebSession <WebRequestSession>] + [-SessionVariable <String>] [-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>] + [-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>] + [-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>] + [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] [-TimeoutSec <Int32>] + [-Headers <IDictionary>] [-MaximumRedirection <Int32>] [-MaximumRetryCount <Int32>] + [-RetryIntervalSec <Int32>] [-Method <WebRequestMethod>] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] + [-ProxyUseDefaultCredentials] [-Body <Object>] [-Form <IDictionary>] [-ContentType <String>] + [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] [-PassThru] [-Resume] + [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] [-SkipHeaderValidation] [<CommonParameters>] ``` ### StandardMethodNoProxy ```-Invoke-WebRequest [-UseBasicParsing] [-Uri] <Uri> [-WebSession <WebRequestSession>] - [-SessionVariable <String>] [-AllowUnencryptedAuthentication] - [-Authentication <WebAuthenticationType>] [-Credential <PSCredential>] [-UseDefaultCredentials] - [-CertificateThumbprint <String>] [-Certificate <X509Certificate>] [-SkipCertificateCheck] - [-SslProtocol <WebSslProtocol>] [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] - [-TimeoutSec <Int32>] [-Headers <IDictionary>] [-MaximumRedirection <Int32>] - [-MaximumRetryCount <Int32>] [-RetryIntervalSec <Int32>] [-Method <WebRequestMethod>] -NoProxy - [-Body <Object>] [-Form <IDictionary>] [-ContentType <String>] [-TransferEncoding <String>] - [-InFile <String>] [-OutFile <String>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] - [-PreserveAuthorizationOnRedirect] [-SkipHeaderValidation] [<CommonParameters>] +Invoke-WebRequest [-UseBasicParsing] [-Uri] <Uri> [-HttpVersion <Version>] [-WebSession <WebRequestSession>] + [-SessionVariable <String>] [-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>] + [-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>] + [-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>] + [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] [-TimeoutSec <Int32>] + [-Headers <IDictionary>] [-MaximumRedirection <Int32>] [-MaximumRetryCount <Int32>] + [-RetryIntervalSec <Int32>] [-Method <WebRequestMethod>] -NoProxy [-Body <Object>] [-Form <IDictionary>] + [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] [-PassThru] + [-Resume] [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] [-SkipHeaderValidation] + [<CommonParameters>] ``` ### CustomMethod ```-Invoke-WebRequest [-UseBasicParsing] [-Uri] <Uri> [-WebSession <WebRequestSession>] - [-SessionVariable <String>] [-AllowUnencryptedAuthentication] - [-Authentication <WebAuthenticationType>] [-Credential <PSCredential>] [-UseDefaultCredentials] - [-CertificateThumbprint <String>] [-Certificate <X509Certificate>] [-SkipCertificateCheck] - [-SslProtocol <WebSslProtocol>] [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] - [-TimeoutSec <Int32>] [-Headers <IDictionary>] [-MaximumRedirection <Int32>] - [-MaximumRetryCount <Int32>] [-RetryIntervalSec <Int32>] -CustomMethod <String> [-Proxy <Uri>] - [-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials] [-Body <Object>] - [-Form <IDictionary>] [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] - [-OutFile <String>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] - [-SkipHeaderValidation] [<CommonParameters>] +Invoke-WebRequest [-UseBasicParsing] [-Uri] <Uri> [-HttpVersion <Version>] [-WebSession <WebRequestSession>] + [-SessionVariable <String>] [-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>] + [-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>] + [-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>] + [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] [-TimeoutSec <Int32>] + [-Headers <IDictionary>] [-MaximumRedirection <Int32>] [-MaximumRetryCount <Int32>] + [-RetryIntervalSec <Int32>] -CustomMethod <String> [-Proxy <Uri>] [-ProxyCredential <PSCredential>] + [-ProxyUseDefaultCredentials] [-Body <Object>] [-Form <IDictionary>] [-ContentType <String>] + [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] [-PassThru] [-Resume] + [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] [-SkipHeaderValidation] [<CommonParameters>] ``` ### CustomMethodNoProxy ```-Invoke-WebRequest [-UseBasicParsing] [-Uri] <Uri> [-WebSession <WebRequestSession>] - [-SessionVariable <String>] [-AllowUnencryptedAuthentication] - [-Authentication <WebAuthenticationType>] [-Credential <PSCredential>] [-UseDefaultCredentials] - [-CertificateThumbprint <String>] [-Certificate <X509Certificate>] [-SkipCertificateCheck] - [-SslProtocol <WebSslProtocol>] [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] - [-TimeoutSec <Int32>] [-Headers <IDictionary>] [-MaximumRedirection <Int32>] - [-MaximumRetryCount <Int32>] [-RetryIntervalSec <Int32>] -CustomMethod <String> -NoProxy - [-Body <Object>] [-Form <IDictionary>] [-ContentType <String>] [-TransferEncoding <String>] - [-InFile <String>] [-OutFile <String>] [-PassThru] [-Resume] [-SkipHttpErrorCheck] - [-PreserveAuthorizationOnRedirect] [-SkipHeaderValidation] [<CommonParameters>] +Invoke-WebRequest [-UseBasicParsing] [-Uri] <Uri> [-HttpVersion <Version>] [-WebSession <WebRequestSession>] + [-SessionVariable <String>] [-AllowUnencryptedAuthentication] [-Authentication <WebAuthenticationType>] + [-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <String>] + [-Certificate <X509Certificate>] [-SkipCertificateCheck] [-SslProtocol <WebSslProtocol>] + [-Token <SecureString>] [-UserAgent <String>] [-DisableKeepAlive] [-TimeoutSec <Int32>] + [-Headers <IDictionary>] [-MaximumRedirection <Int32>] [-MaximumRetryCount <Int32>] + [-RetryIntervalSec <Int32>] -CustomMethod <String> -NoProxy [-Body <Object>] [-Form <IDictionary>] + [-ContentType <String>] [-TransferEncoding <String>] [-InFile <String>] [-OutFile <String>] [-PassThru] + [-Resume] [-SkipHttpErrorCheck] [-PreserveAuthorizationOnRedirect] [-SkipHeaderValidation] + [<CommonParameters>] ``` ## Description $StatusCode The terminating error is caught by the `catch` block, which retrieves the **StatusCode** from the **Exception** object. +### Example 8: Send a request using HTTP 2.0 ++This example gets the links in a web page using the HTTP 2.0 protocol. It uses the +`Invoke-WebRequest` cmdlet to get the web page content. Then it uses the **Links** property of the +`BasicHtmlWebResponseObject` that `Invoke-WebRequest` returns, and the **Href** property of each +link. ++```powershell +(Invoke-WebRequest -Uri 'https://aka.ms/pscore6-docs' -HttpVersion 2.0).Links.Href +``` + ## Parameters ### -AllowUnencryptedAuthentication Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Accept pipeline input: False Accept wildcard characters: False ``` +### -HttpVersion ++Specifies the HTTP version used for the request. The default is `1.1`. ++Valid values are: ++- 1.0 +- 1.1 +- 2.0 +- 3.0 ++```yaml +Type: System.Version +Parameter Sets: (All) +Aliases: ++Required: False +Position: Named +Default value: 1.1 +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -InFile Gets the content of the web request from a file. Enter a path and file name. If you omit the path, Aliases: Required: True Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` Aliases: Required: False Position: Named-Default value: None +Default value: False Accept pipeline input: False Accept wildcard characters: False ``` |
install | Install Ubuntu | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/install/install-ubuntu.md | --- description: Information about installing PowerShell on Ubuntu Previously updated : 11/08/2021 Last updated : 01/24/2022 Title: Installing PowerShell on Ubuntu --- # Installing PowerShell on Ubuntu the version you downloaded. ```sh # Install the downloaded package-sudo dpkg -i powershell_7.2.1-1.deb_amd64.deb +sudo dpkg -i powershell-lts_7.2.1-1.deb_amd64.deb # Resolve missing dependencies and finish the install (if necessary) sudo apt-get install -f |
windows-powershell | Release Notes | https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/docs-conceptual/windows-powershell/wmf/whats-new/release-notes.md | present, this resulted in an error. In WMF 5.1: - You can use- [ModuleSpecification Constructor (Hashtable)](/dotnet/api/microsoft.powershell.commands.modulespecification.-ctor#Microsoft_PowerShell_Commands_ModuleSpecification__ctor_System_Collections_Hashtable_). + [ModuleSpecification Constructor (Hashtable)](/dotnet/api/microsoft.powershell.commands.modulespecification.-ctor#microsoft-powershell-commands-modulespecification-ctor(system-collections-hashtable)). This hash table has the same format as `Get-Module -FullyQualifiedName`. |