diff --git a/src/Accounts/Accounts/Az.Accounts.psd1 b/src/Accounts/Accounts/Az.Accounts.psd1 index 09d540fe8c5d..88495d1cb67c 100644 --- a/src/Accounts/Accounts/Az.Accounts.psd1 +++ b/src/Accounts/Accounts/Az.Accounts.psd1 @@ -78,7 +78,8 @@ RequiredAssemblies = 'Microsoft.Azure.PowerShell.Authentication.Abstractions.dll 'Microsoft.WindowsAzure.Storage.dll', 'Microsoft.WindowsAzure.Storage.DataMovement.dll', 'Microsoft.Azure.PowerShell.Clients.Aks.dll', - 'Microsoft.Azure.PowerShell.Strategies.dll' + 'Microsoft.Azure.PowerShell.Strategies.dll', + 'Microsoft.Azure.PowerShell.Common.Share.dll' # Script files (.ps1) that are run in the caller's environment prior to importing this module. # ScriptsToProcess = @() @@ -106,7 +107,8 @@ CmdletsToExport = 'Disable-AzDataCollection', 'Disable-AzContextAutosave', 'Disconnect-AzAccount', 'Get-AzContextAutosaveSetting', 'Set-AzDefault', 'Get-AzDefault', 'Clear-AzDefault', 'Register-AzModule', 'Enable-AzureRmAlias', 'Disable-AzureRmAlias', - 'Uninstall-AzureRm', 'Invoke-AzRestMethod', 'Get-AzAccessToken' + 'Uninstall-AzureRm', 'Invoke-AzRestMethod', 'Get-AzAccessToken', + 'Open-AzSurveyLink' # Variables to export from this module # VariablesToExport = @() diff --git a/src/Accounts/Accounts/ChangeLog.md b/src/Accounts/Accounts/ChangeLog.md index a0168756551b..aec266bef508 100644 --- a/src/Accounts/Accounts/ChangeLog.md +++ b/src/Accounts/Accounts/ChangeLog.md @@ -19,6 +19,7 @@ --> ## Upcoming Release +* Added cmdlet `Open-AzSurveyLink` * Supported certificate file as input parameter of Connect-AzAccount ## Version 2.3.0 diff --git a/src/Accounts/Accounts/Feedback/OpenAzSurveyLinkCmdlet.cs b/src/Accounts/Accounts/Feedback/OpenAzSurveyLinkCmdlet.cs new file mode 100644 index 000000000000..6e5d67b2ab3f --- /dev/null +++ b/src/Accounts/Accounts/Feedback/OpenAzSurveyLinkCmdlet.cs @@ -0,0 +1,66 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using Microsoft.Azure.Commands.Common.Authentication.Abstractions; +using Microsoft.WindowsAzure.Commands.Utilities.Common; +using System; +using System.Diagnostics; +using System.Management.Automation; +using System.Runtime.InteropServices; + +namespace Microsoft.Azure.Commands.Profile.Survey +{ + [Cmdlet(VerbsCommon.Open, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "SurveyLink"), OutputType(typeof(void))] + public class OpenAzSurveyLinkCmdlet : AzurePSCmdlet + { + private const string _surveyLinkFormat = "https://aka.ms/azpssurvey?Q_CHL=INTERCEPT"; + + protected override IAzureContext DefaultContext => null; + + protected override string DataCollectionWarning => null; + + public override void ExecuteCmdlet() + { + WriteInformation(new HostInformationMessage() { Message = $"Opening the default browser to {_surveyLinkFormat}" }, new string[] { "PSHOST" }); + OpenBrowser(_surveyLinkFormat); + } + + private void OpenBrowser(string url) + { + try + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + url = url.Replace("&", "^&"); + Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true }); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + Process.Start("xdg-open", url); + } + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + Process.Start("open", url); + } + else + { + throw new PlatformNotSupportedException(RuntimeInformation.OSDescription); + } + } + catch + { + } + } + } +} \ No newline at end of file diff --git a/src/Accounts/Accounts/help/Az.Accounts.md b/src/Accounts/Accounts/help/Az.Accounts.md index d2b4318cc2d3..c05e40b851cb 100644 --- a/src/Accounts/Accounts/help/Az.Accounts.md +++ b/src/Accounts/Accounts/help/Az.Accounts.md @@ -81,6 +81,9 @@ Loads Azure authentication information from a file. ### [Invoke-AzRestMethod](Invoke-AzRestMethod.md) Construct and perform HTTP request to Azure resource management endpoint only +### [Open-AzSurveyLink](Open-AzSurveyLink.md) +Open survey link in default browser. + ### [Register-AzModule](Register-AzModule.md) FOR INTERNAL USE ONLY - Provide Runtime Support for AutoRest Generated cmdlets diff --git a/src/Accounts/Accounts/help/Open-AzSurveyLink.md b/src/Accounts/Accounts/help/Open-AzSurveyLink.md new file mode 100644 index 000000000000..d0dea213f408 --- /dev/null +++ b/src/Accounts/Accounts/help/Open-AzSurveyLink.md @@ -0,0 +1,58 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Accounts.dll-Help.xml +Module Name: Az.Accounts +online version: https://docs.microsoft.com/powershell/module/az.accounts/open-azsurveylink +schema: 2.0.0 +--- + +# Open-AzSurveyLink + +## SYNOPSIS +Open survey link in default browser. + +## SYNTAX + +``` +Open-AzSurveyLink [-DefaultProfile ] [] +``` + +## DESCRIPTION +Open survey link in default browser. + +## EXAMPLES + +### Example 1 +``` +Open-AzSurveyLink +Opening the default browser to https://aka.ms/azpssurvey?Q_CHL=INTERCEPT +``` + +## PARAMETERS + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### None + +## OUTPUTS + +## NOTES + +## RELATED LINKS diff --git a/tools/Common.Netcore.Dependencies.targets b/tools/Common.Netcore.Dependencies.targets index 2caef4b2feee..2010ef8fdf8f 100644 --- a/tools/Common.Netcore.Dependencies.targets +++ b/tools/Common.Netcore.Dependencies.targets @@ -3,21 +3,22 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -35,7 +36,7 @@ - $(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.34-preview\tools\ + $(NugetPackageRoot)\microsoft.azure.powershell.storage\1.3.36-preview\tools\ diff --git a/tools/StaticAnalysis/Exceptions/Az.Accounts/SignatureIssues.csv b/tools/StaticAnalysis/Exceptions/Az.Accounts/SignatureIssues.csv new file mode 100644 index 000000000000..1583eddd078b --- /dev/null +++ b/tools/StaticAnalysis/Exceptions/Az.Accounts/SignatureIssues.csv @@ -0,0 +1,2 @@ +"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation" +"Az.Accounts","Microsoft.Azure.Commands.Profile.Survey.OpenAzSurveyLinkCmdlet","Open-AzSurveyLink","1","8100","Open-AzSurveyLink Does not support ShouldProcess but the cmdlet verb Open indicates that it should.","Determine if the cmdlet should implement ShouldProcess and if so determine if it should implement Force / ShouldContinue" \ No newline at end of file