forked from microsoftgraph/msgraph-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecodeAndWrite.ps1
More file actions
32 lines (28 loc) · 1013 Bytes
/
decodeAndWrite.ps1
File metadata and controls
32 lines (28 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
<#
.Synopsis
Decode the encoded string and write it to a local file.
.Description
Receives an encoded string value and decodes it using base64.
Write the new decoded string to a local file for later consumption.
.Parameter encodedValue
The encoded string we wish to decode.
.Parameter outputPath
The file path that we wish to write the decoded value to.
#>
Param(
[string]$encodedValue ,
[string]$outputPath
)
if($outputPath -eq "" -or $null -eq $outputPath) {
Write-Output "Value of Variable: outputPath is Null or Empty. Exiting."
Exit
}
if($encodedValue -eq "" -or $null -eq $encodedValue) {
Write-Output "Value of Variable: encodedValue is Null of Empty. Exiting."
Exit
}
$decodedValue = [System.Convert]::FromBase64String($encodedValue)
$targetFullPath = Join-Path $PWD -ChildPath $outputPath
[System.IO.File]::WriteAllBytes($targetFullPath, $decodedValue)