-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add cmdlet open-azsurveylink (#15205)
* add cmdlet open-azsurveylink * move new cmdlet under feedback folder * remove white space * add help markdown for new cmdlet * update common version * suppress signature issue * update parent class * update namespace for share assembly * upgrade common version * add example * fix help markdown * add required assembly
- Loading branch information
Showing
7 changed files
with
151 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <IAzureContextContainer>] [<CommonParameters>] | ||
``` | ||
|
||
## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
tools/StaticAnalysis/Exceptions/Az.Accounts/SignatureIssues.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |