Skip to content

Commit 3a6c69a

Browse files
author
Maddie Clayton
authored
Merge pull request #6986 from maddieclayton/resolvepath
Add proper path resolution to -Path/File parameters
2 parents f6efc22 + 7c53ff5 commit 3a6c69a

File tree

78 files changed

+123
-111
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+123
-111
lines changed

src/ResourceManager/Automation/Commands.Automation/Cmdlet/ExportAzureAutomationDscConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public override void ExecuteCmdlet()
7373
if (ShouldProcess(Name, VerbsData.Export))
7474
{
7575
var ret = this.AutomationClient.GetConfigurationContent(this.ResourceGroupName,
76-
this.AutomationAccountName, this.Name, isDraft, OutputFolder, this.Force);
76+
this.AutomationAccountName, this.Name, isDraft, ResolveUserPath(OutputFolder), this.Force);
7777

7878
this.WriteObject(ret, true);
7979
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/ExportAzureAutomationDscNodeReportContent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public override void ExecuteCmdlet()
7070
if (ShouldProcess(ReportId.ToString(), VerbsData.Export))
7171
{
7272
var ret = this.AutomationClient.GetDscNodeReportContent(this.ResourceGroupName,
73-
this.AutomationAccountName, this.NodeId, this.ReportId, OutputFolder, overwriteExistingFile);
73+
this.AutomationAccountName, this.NodeId, this.ReportId, ResolveUserPath(OutputFolder), overwriteExistingFile);
7474

7575
this.WriteObject(ret, true);
7676
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/ExportAzureAutomationRunbook.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected override void AutomationProcessRecord()
6666
if (ShouldProcess(Name, VerbsData.Export))
6767
{
6868
var outputFolder = this.AutomationClient.ExportRunbook(this.ResourceGroupName,
69-
this.AutomationAccountName, this.Name, isDraft, this.OutputFolder, this.Force.IsPresent);
69+
this.AutomationAccountName, this.Name, isDraft, ResolveUserPath(this.OutputFolder), this.Force.IsPresent);
7070

7171
this.WriteObject(outputFolder, true);
7272
}

src/ResourceManager/Automation/Commands.Automation/Cmdlet/GetAzureAutomationDscOnboardingMetaconfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public SwitchParameter Force
6060
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
6161
public override void ExecuteCmdlet()
6262
{
63+
OutputFolder = ResolveUserPath(OutputFolder);
6364
this.ConfirmAction(
6465
this.Force.IsPresent,
6566
string.Format(CultureInfo.CurrentCulture, Resources.DscMetaMofHasKeysWarning),

src/ResourceManager/Automation/Commands.Automation/Cmdlet/ImportAzureAutomationDscConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public override void ExecuteCmdlet()
9494
var configuration = this.AutomationClient.CreateConfiguration(
9595
this.ResourceGroupName,
9696
this.AutomationAccountName,
97-
this.SourcePath,
97+
ResolveUserPath(this.SourcePath),
9898
this.Tags,
9999
this.Description,
100100
this.LogVerbose,

src/ResourceManager/Automation/Commands.Automation/Cmdlet/ImportAzureAutomationDscNodeConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public override void ExecuteCmdlet()
7777
{
7878
if (ShouldProcess(Path, VerbsData.Import))
7979
{
80+
Path = ResolveUserPath(Path);
8081
var nodeName = System.IO.Path.GetFileNameWithoutExtension(Path);
8182
var nodeConfigurationName = ConfigurationName + "." + nodeName;
8283
NodeConfiguration nodeConfigurationModel = null;

src/ResourceManager/Automation/Commands.Automation/Cmdlet/NewAzureAutomationCertificate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public class NewAzureAutomationCertificate : AzureAutomationBaseCmdlet
7070
protected override void AutomationProcessRecord()
7171
{
7272

73-
var createdCertificate = this.AutomationClient.CreateCertificate(this.ResourceGroupName, this.AutomationAccountName, this.Name, this.ResolvePath(this.Path), this.Password, this.Description, this.Exportable.IsPresent);
73+
var createdCertificate = this.AutomationClient.CreateCertificate(this.ResourceGroupName, this.AutomationAccountName, this.Name, this.ResolvePath(Path), this.Password, this.Description, this.Exportable.IsPresent);
7474

7575
this.WriteObject(createdCertificate);
7676
}

src/ResourceManager/Automation/Commands.Automation/Common/AutomationClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ private DirectoryInfo WriteRunbookToFile(string outputFolder, string runbookName
18951895

18961896
var fileExtension = IsGraphRunbook(runbookType) ? Constants.SupportedFileExtensions.Graph : Constants.SupportedFileExtensions.PowerShellScript;
18971897

1898-
var outputFilePath = outputFolderFullPath + "\\" + runbookName + fileExtension;
1898+
var outputFilePath = Path.Combine(outputFolderFullPath, runbookName + fileExtension);
18991899

19001900
// file exists and overwrite Not specified
19011901
if (File.Exists(outputFilePath) && !overwriteExistingFile)

src/ResourceManager/AzureBatch/Commands.Batch/Files/GetBatchNodeFileContentCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public class GetBatchNodeFileContentCommand : BatchObjectModelCmdletBase
9696

9797
public override void ExecuteCmdlet()
9898
{
99+
DestinationPath = ResolveUserPath(DestinationPath);
99100
if (this.ByteRangeEnd != null && this.ByteRangeStart == null)
100101
{
101102
this.ByteRangeStart = 0;

src/ResourceManager/Compute/Commands.Compute/VirtualMachine/Action/SaveAzureVMImageCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public override void ExecuteCmdlet()
8888
result.EndTime = DateTime.Now;
8989
if (!string.IsNullOrWhiteSpace(this.Path))
9090
{
91-
File.WriteAllText(this.Path, op.Body.Resources[0].ToString());
91+
File.WriteAllText(ResolveUserPath(this.Path), op.Body.Resources[0].ToString());
9292
}
9393
WriteObject(result);
9494
});

src/ResourceManager/DataLakeStore/Commands.DataLakeStore/DataPlaneCommands/ExportAzureRmDataLakeStoreItem.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public class ExportAzureDataLakeStoreItem : DataLakeStoreFileSystemCmdletBase
109109
public override void ExecuteCmdlet()
110110
{
111111
// We will let this throw itself if the path they give us is invalid
112-
var powerShellReadyPath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(Destination);
112+
var powerShellReadyPath = ResolveUserPath(Destination);
113113
ConfirmAction(
114114
VerbsData.Export,
115115
Path.TransformedPath,
@@ -119,8 +119,7 @@ public override void ExecuteCmdlet()
119119
{
120120
if (ParameterSetName.Equals(DiagnosticParameterSetName) && DiagnosticLogLevel != LogLevel.None)
121121
{
122-
var diagnosticPath =
123-
SessionState.Path.GetUnresolvedProviderPathFromPSPath(DiagnosticLogPath);
122+
var diagnosticPath = ResolveUserPath(DiagnosticLogPath);
124123
DataLakeStoreFileSystemClient.SetupFileLogging(DiagnosticLogLevel, diagnosticPath);
125124
}
126125

src/ResourceManager/DataLakeStore/Commands.DataLakeStore/DataPlaneCommands/ImportAzureRmDataLakeStoreItem.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public class ImportAzureDataLakeStoreItem : DataLakeStoreFileSystemCmdletBase
118118

119119
public override void ExecuteCmdlet()
120120
{
121-
var powerShellSourcePath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(Path);
121+
var powerShellSourcePath = ResolveUserPath(Path);
122122
ConfirmAction(
123123
Resources.UploadFileMessage,
124124
Destination.TransformedPath,
@@ -128,8 +128,7 @@ public override void ExecuteCmdlet()
128128
{
129129
if (ParameterSetName.Equals(DiagnosticParameterSetName) && DiagnosticLogLevel != LogLevel.None)
130130
{
131-
var diagnosticPath =
132-
SessionState.Path.GetUnresolvedProviderPathFromPSPath(DiagnosticLogPath);
131+
var diagnosticPath = ResolveUserPath(DiagnosticLogPath);
133132
DataLakeStoreFileSystemClient.SetupFileLogging(DiagnosticLogLevel, diagnosticPath);
134133
}
135134

src/ResourceManager/DeviceProvisioningServices/Commands.DeviceProvisioningServices/Cmdlet/IotDpsCertificates/AddAzureRmIotDeviceProvisioningServiceCertificate.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public class AddAzureRmIoTDeviceProvisioningServiceCertificate : IotDpsBaseCmdle
114114

115115
public override void ExecuteCmdlet()
116116
{
117+
Path = ResolveUserPath(Path);
117118
if (ShouldProcess(Name, DPSResources.AddCertificate))
118119
{
119120
switch (ParameterSetName)

src/ResourceManager/DeviceProvisioningServices/Commands.DeviceProvisioningServices/Cmdlet/IotDpsCertificates/SetAzureRmIotDeviceProvisioningServiceCertificate.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public class SetAzureRmIoTDeviceProvisioningServiceCertificate : IotDpsBaseCmdle
111111

112112
public override void ExecuteCmdlet()
113113
{
114+
Path = ResolveUserPath(Path);
114115
if (ShouldProcess(Name, DPSResources.SetCertificate))
115116
{
116117
switch (ParameterSetName)

src/ResourceManager/IotHub/Commands.IotHub/IotHub/AddAzureRmIotHubCertificate.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public class AddAzureRmIotHubCertificate : IotHubBaseCmdlet
104104

105105
public override void ExecuteCmdlet()
106106
{
107+
Path = ResolveUserPath(Path);
107108
if (ShouldProcess(CertificateName, Properties.Resources.AddIotHubCertificate))
108109
{
109110
string certificate = string.Empty;

src/ResourceManager/IotHub/Commands.IotHub/IotHub/SetAzureRmIotHubVerifiedCertificate.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public class SetAzureRmIotHubVerifiedCertificate : IotHubBaseCmdlet
112112

113113
public override void ExecuteCmdlet()
114114
{
115+
Path = ResolveUserPath(Path);
115116
if (ShouldProcess(CertificateName, Properties.Resources.VerifyIotHubCertificate))
116117
{
117118
string certificate = string.Empty;

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/ImportAzureKeyVaultCertificate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public override void ExecuteCmdlet()
179179

180180
internal X509Certificate2Collection InitializeCertificateCollection()
181181
{
182-
FileInfo certFile = new FileInfo(this.GetUnresolvedProviderPathFromPSPath(this.FilePath));
182+
FileInfo certFile = new FileInfo(ResolveUserPath(this.FilePath));
183183
if (!certFile.Exists)
184184
{
185185
throw new FileNotFoundException(string.Format(KeyVaultProperties.Resources.CertificateFileNotFound, this.FilePath));

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/ManagedStorageAccounts/RestoreAzureKeyVaultManagedStorageAccount.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public override void ExecuteCmdlet()
9595

9696
if (ShouldProcess(VaultName, Properties.Resources.RestoreManagedStorageAccount))
9797
{
98-
var resolvedFilePath = this.GetUnresolvedProviderPathFromPSPath(InputFile);
98+
var resolvedFilePath = this.ResolveUserPath(InputFile);
9999

100100
if (!AzureSession.Instance.DataStore.FileExists(resolvedFilePath))
101101
{

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/RestoreAzureKeyVaultCertificate.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public override void ExecuteCmdlet()
9595

9696
if (ShouldProcess(VaultName, Properties.Resources.RestoreCertificate))
9797
{
98-
var resolvedFilePath = this.GetUnresolvedProviderPathFromPSPath(InputFile);
98+
var resolvedFilePath = this.ResolveUserPath(InputFile);
9999

100100
if (!AzureSession.Instance.DataStore.FileExists(resolvedFilePath))
101101
{

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/RestoreAzureKeyVaultKey.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,17 @@ public override void ExecuteCmdlet()
9494

9595
if (ShouldProcess(VaultName, Properties.Resources.RestoreKey))
9696
{
97-
var filePath = ResolvePath(InputFile);
97+
var filePath = ResolveKeyVaultPath(InputFile);
9898

9999
var restoredKeyBundle = this.DataServiceClient.RestoreKey(VaultName, filePath);
100100

101101
this.WriteObject(restoredKeyBundle);
102102
}
103103
}
104104

105-
private string ResolvePath(string filePath)
105+
private string ResolveKeyVaultPath(string filePath)
106106
{
107-
FileInfo keyFile = new FileInfo(this.GetUnresolvedProviderPathFromPSPath(filePath));
107+
FileInfo keyFile = new FileInfo(this.ResolveUserPath(filePath));
108108
if (!keyFile.Exists)
109109
{
110110
throw new FileNotFoundException(string.Format(Resources.BackupKeyFileNotFound, filePath));

src/ResourceManager/KeyVault/Commands.KeyVault/Commands/RestoreAzureKeyVaultSecret.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public override void ExecuteCmdlet( )
9595

9696
if (ShouldProcess(VaultName, Properties.Resources.RestoreSecret))
9797
{
98-
var resolvedFilePath = this.GetUnresolvedProviderPathFromPSPath(InputFile);
98+
var resolvedFilePath = this.ResolveUserPath(InputFile);
9999

100100
if (!AzureSession.Instance.DataStore.FileExists(resolvedFilePath))
101101
{

src/ResourceManager/Profile/Commands.Profile/Context/ImportAzureRMContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public override void ExecuteCmdlet()
5151
bool executionComplete = false;
5252
if (MyInvocation.BoundParameters.ContainsKey("Path"))
5353
{
54+
Path = this.ResolveUserPath(Path);
5455
ConfirmAction(string.Format(Resources.ProcessImportContextFromFile, Path), Resources.ImportContextTarget, () =>
5556
{
5657
if (!AzureSession.Instance.DataStore.FileExists(Path))

src/ResourceManager/Profile/Commands.Profile/Context/SaveAzureRMContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class SaveAzureRMContextCommand : AzureRMCmdlet
4242

4343
public override void ExecuteCmdlet()
4444
{
45+
Path = this.ResolveUserPath(Path);
4546
if (Profile != null)
4647
{
4748
if (ShouldProcess(string.Format(Resources.ProfileArgumentWrite, Path),

src/ResourceManager/Profile/Commands.Profile/packages.config

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@
1010
<package id="Microsoft.Azure.Management.Authorization" version="2.0.0" targetFramework="net45" />
1111
<package id="Microsoft.Azure.Management.ResourceManager" version="1.9.0-preview" targetFramework="net452" />
1212
<package id="Microsoft.Azure.Management.Resources" version="2.20.1-preview" targetFramework="net452" />
13-
<package id="Microsoft.Azure.PowerShell.Aks" version="1.0.93-preview" targetFramework="net452" />
14-
<package id="Microsoft.Azure.PowerShell.Authentication" version="1.0.93-preview" targetFramework="net452" />
15-
<package id="Microsoft.Azure.PowerShell.Authentication.Abstractions" version="1.0.93-preview" targetFramework="net452" />
16-
<package id="Microsoft.Azure.PowerShell.Authentication.ResourceManager" version="1.0.93-preview" targetFramework="net452" />
17-
<package id="Microsoft.Azure.PowerShell.Authorization" version="1.0.93-preview" targetFramework="net452" />
18-
<package id="Microsoft.Azure.PowerShell.Common" version="1.0.93-preview" targetFramework="net452" />
19-
<package id="Microsoft.Azure.PowerShell.Compute" version="1.0.93-preview" targetFramework="net452" />
20-
<package id="Microsoft.Azure.PowerShell.Graph.Rbac" version="1.0.93-preview" targetFramework="net452" />
21-
<package id="Microsoft.Azure.PowerShell.KeyVault" version="1.0.93-preview" targetFramework="net452" />
22-
<package id="Microsoft.Azure.PowerShell.Network" version="1.0.93-preview" targetFramework="net452" />
23-
<package id="Microsoft.Azure.PowerShell.ResourceManager" version="1.0.93-preview" targetFramework="net452" />
24-
<package id="Microsoft.Azure.PowerShell.ScenarioTest.ResourceManager" version="1.0.93-preview" targetFramework="net452" />
25-
<package id="Microsoft.Azure.PowerShell.ServiceManagement" version="1.0.93-preview" targetFramework="net452" />
26-
<package id="Microsoft.Azure.PowerShell.Storage" version="1.0.93-preview" targetFramework="net452" />
27-
<package id="Microsoft.Azure.PowerShell.Storage.Management" version="1.0.93-preview" targetFramework="net452" />
28-
<package id="Microsoft.Azure.PowerShell.Strategies" version="1.0.93-preview" targetFramework="net452" />
29-
<package id="Microsoft.Azure.PowerShell.Websites" version="1.0.93-preview" targetFramework="net452" />
13+
<package id="Microsoft.Azure.PowerShell.Aks" version="1.0.94-preview" targetFramework="net452" />
14+
<package id="Microsoft.Azure.PowerShell.Authentication" version="1.0.94-preview" targetFramework="net452" />
15+
<package id="Microsoft.Azure.PowerShell.Authentication.Abstractions" version="1.0.94-preview" targetFramework="net452" />
16+
<package id="Microsoft.Azure.PowerShell.Authentication.ResourceManager" version="1.0.94-preview" targetFramework="net452" />
17+
<package id="Microsoft.Azure.PowerShell.Authorization" version="1.0.94-preview" targetFramework="net452" />
18+
<package id="Microsoft.Azure.PowerShell.Common" version="1.0.94-preview" targetFramework="net452" />
19+
<package id="Microsoft.Azure.PowerShell.Compute" version="1.0.94-preview" targetFramework="net452" />
20+
<package id="Microsoft.Azure.PowerShell.Graph.Rbac" version="1.0.94-preview" targetFramework="net452" />
21+
<package id="Microsoft.Azure.PowerShell.KeyVault" version="1.0.94-preview" targetFramework="net452" />
22+
<package id="Microsoft.Azure.PowerShell.Network" version="1.0.94-preview" targetFramework="net452" />
23+
<package id="Microsoft.Azure.PowerShell.ResourceManager" version="1.0.94-preview" targetFramework="net452" />
24+
<package id="Microsoft.Azure.PowerShell.ScenarioTest.ResourceManager" version="1.0.94-preview" targetFramework="net452" />
25+
<package id="Microsoft.Azure.PowerShell.ServiceManagement" version="1.0.94-preview" targetFramework="net452" />
26+
<package id="Microsoft.Azure.PowerShell.Storage" version="1.0.94-preview" targetFramework="net452" />
27+
<package id="Microsoft.Azure.PowerShell.Storage.Management" version="1.0.94-preview" targetFramework="net452" />
28+
<package id="Microsoft.Azure.PowerShell.Strategies" version="1.0.94-preview" targetFramework="net452" />
29+
<package id="Microsoft.Azure.PowerShell.Websites" version="1.0.94-preview" targetFramework="net452" />
3030
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net452" />
3131
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.8.1" targetFramework="net452" />
3232
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net452" />

src/ResourceManager/RecoveryServices.SiteRecovery/Commands.RecoveryServices.SiteRecovery/RecoveryPlan/GetAzureRmRecoveryServicesAsrRecoveryPlan.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private void GetRecoveryPlanFile(
188188
System.IO.Path.GetDirectoryName(this.Path)));
189189
}
190190

191-
var fullFileName = this.Path;
191+
var fullFileName = ResolveUserPath(this.Path);
192192
using (var file = new StreamWriter(
193193
fullFileName,
194194
false))

src/ResourceManager/RecoveryServices.SiteRecovery/Commands.RecoveryServices.SiteRecovery/RecoveryPlan/NewAzureRmRecoveryServicesAsrRecoveryPlan.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,18 @@ public override void ExecuteSiteRecoveryCmdlet()
152152
break;
153153
case ASRParameterSets.ByRPFile:
154154

155-
if (!File.Exists(this.Path))
155+
var filePath = ResolveUserPath(this.Path);
156+
157+
if (!File.Exists(filePath))
156158
{
157159
throw new FileNotFoundException(
158160
string.Format(
159161
Resources.FileNotFound,
160-
this.Path));
162+
filePath));
161163

162164
;
163165
}
164166

165-
var filePath = this.Path;
166-
167167
using (var file = new StreamReader(filePath))
168168
{
169169
this.recoveryPlan = JsonConvert.DeserializeObject<RecoveryPlan>(

src/ResourceManager/RecoveryServices.SiteRecovery/Commands.RecoveryServices.SiteRecovery/RecoveryPlan/UpdateAzureRmRecoveryServicesAsrRecoveryPlan.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ public override void ExecuteSiteRecoveryCmdlet()
6868
break;
6969
case ASRParameterSets.ByRPFile:
7070

71-
if (!File.Exists(this.Path))
71+
var filePath = ResolveUserPath(this.Path);
72+
73+
if (!File.Exists(filePath))
7274
{
7375
throw new FileNotFoundException(
7476
string.Format(
7577
Resources.FileNotFound,
76-
this.Path));
78+
filePath));
7779
;
7880
}
7981

80-
var filePath = this.Path;
81-
8282
RecoveryPlan recoveryPlan = null;
8383

8484
using (var file = new StreamReader(filePath))

src/ResourceManager/RecoveryServices.SiteRecovery/Commands.RecoveryServices.SiteRecovery/Vault/ImportAzureRmRecoveryServicesAsrVaultSettingsFile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public override void ExecuteSiteRecoveryCmdlet()
5252
{
5353
base.ExecuteSiteRecoveryCmdlet();
5454

55+
Path = this.ResolveUserPath(Path);
56+
5557
if (this.ShouldProcess(
5658
"Vault Setting file",
5759
VerbsData.Import))

src/ResourceManager/RecoveryServices/Commands.RecoveryServices.Backup/Cmdlets/RecoveryPoint/GetAzureRmRecoveryServicesBackupRPMountScript.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public override void ExecuteCmdlet()
6161
{ VaultParams.VaultName, vaultName },
6262
{ VaultParams.ResourceGroupName, resourceGroupName },
6363
{ RestoreBackupItemParams.RecoveryPoint, RecoveryPoint },
64-
{ RecoveryPointParams.FileDownloadLocation, Path }
64+
{ RecoveryPointParams.FileDownloadLocation, ResolveUserPath(Path) }
6565
}, ServiceClientAdapter);
6666

6767
IPsBackupProvider psBackupProvider = providerManager.GetProviderInstance(

src/ResourceManager/RecoveryServices/Commands.RecoveryServices/Vault/GetAzureRMRecoveryServicesVaultSettingsFile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ private void GetSiteRecoveryCredentials()
169169
string fileName = this.GenerateFileName();
170170

171171
string filePath = string.IsNullOrEmpty(this.Path) ? Utilities.GetDefaultPath() : this.Path;
172+
filePath = ResolveUserPath(filePath);
172173

173174
// Generate file.
174175
if (RecoveryServicesClient.getVaultAuthType(this.Vault.ResourceGroupName, this.Vault.Name) == 0)
@@ -262,6 +263,7 @@ private string GenerateFileName()
262263
public void GetAzureRMRecoveryServicesVaultBackupCredentials()
263264
{
264265
string targetLocation = string.IsNullOrEmpty(this.Path) ? Utilities.GetDefaultPath() : this.Path;
266+
targetLocation = ResolveUserPath(targetLocation);
265267
if (!Directory.Exists(targetLocation))
266268
{
267269
throw new ArgumentException(Resources.VaultCredPathException);

0 commit comments

Comments
 (0)