Skip to content

Commit 55f0d4e

Browse files
authored
Merge pull request MicrosoftDocs#9974 from MicrosoftDocs/chrisda
Get/Set-Content -Encoding Byte fixe
2 parents 716f24b + dfbd217 commit 55f0d4e

16 files changed

+52
-117
lines changed

skype/skype-ps/skype/Export-CsLisConfiguration.md

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ ms.reviewer:
1616
Exports an Enterprise Voice Enhanced 9-1-1 (E9-1-1) configuration to a file in compressed format for backup purposes.
1717
This cmdlet was introduced in Lync Server 2010.
1818

19-
2019
## SYNTAX
2120

2221
### FileName
@@ -44,7 +43,6 @@ To return a list of all the role-based access control (RBAC) roles this cmdlet h
4443

4544
`Get-CsAdminRole | Where-Object {$_.Cmdlets -match "Export-CsLisConfiguration"}`
4645

47-
4846
## EXAMPLES
4947

5048
### -------------------------- Example 1 --------------------------
@@ -65,27 +63,20 @@ In this example, the LIS configuration is stored as an array of bytes in a varia
6563
```
6664
$lisconfig = Export-CsLisConfiguration -AsBytes
6765
68-
$lisconfig | Set-Content -Path C:\E911Config.bak -Encoding byte
66+
[System.IO.File]::WriteAllBytes('C:\E911Config.bak', $lisconfig)
6967
70-
Get-Content -ReadCount 0 -Encoding byte -Path C:\E911Config.bak | Import-CsLisConfiguration
68+
[System.IO.File]::ReadAllBytes('C:\E911Config.bak') | Import-CsLisConfiguration
7169
```
7270

7371
Example 3 is a more complete version of Example 2.
7472
The first line is the same, we call the Export-CsLisConfiguration cmdlet with the AsBytes parameter to store the LIS configuration as an array of bytes in the variable $lisconfig.
7573
The rest of this example shows how to save that configuration to a file and then import it back into the location configuration database.
7674

77-
In line 2 we pipe the contents of $lisconfig, which is the byte array representing the LIS configuration, to the Windows PowerShell Set-Content cmdlet.
78-
We assign values to two parameters of the Set-Content cmdlet: Path and Encoding.
79-
We assign the full path and file name of the file to which we want to save the configuration to the Path parameter.
80-
We use the Encoding parameter with a value of byte to ensure the configuration is stored as an array of bytes.
75+
In line 2 we pipe the contents of $lisconfig, which is the byte array representing the LIS configuration, to the full path and file name of the file to which we want to save the configuration.
8176

8277
Finally, in line 3 we import the configuration back into the location configuration database.
83-
First we call the Get-Content cmdlet to retrieve the contents from the file.
84-
We pass a value of 0 to the ReadCount property, which tells the Get-Content cmdlet to read all the contents of the file at once rather than one line at a time.
85-
We again use the Encoding parameter with a value of byte to specify what type of data we're reading from the file.
86-
Finally we pass the file name to the Path parameter.
87-
The contents of the file that we read with the Get-Content cmdlet are piped to the Import-CsLisConfiguration cmdlet, which imports the saved configuration into the location database.
88-
78+
First we retrieve the contents from the file.
79+
The contents of the file are then piped to the Import-CsLisConfiguration cmdlet, which imports the saved configuration into the location database.
8980

9081
## PARAMETERS
9182

@@ -134,16 +125,13 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
134125
135126
### None
136127
137-
138128
## OUTPUTS
139129
140130
### Byte[]
141131
Returns a byte array when the AsBytes parameter is used.
142132
143-
144133
## NOTES
145134
146-
147135
## RELATED LINKS
148136
149137
[Import-CsLisConfiguration](Import-CsLisConfiguration.md)

skype/skype-ps/skype/Get-CsCallParkOrbit.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ It does this by checking the StartsWith property of the NumberRangeStart object
8787

8888
### -------------------------- Example 6 --------------------------
8989
```
90-
Get-CsCallParkOrbit | Where-Object {\[Char\]::IsDigit($_.NumberRangeStart\[0\])}
90+
Get-CsCallParkOrbit | Where-Object {[Char]::IsDigit($_.NumberRangeStart[0])}
9191
```
9292

9393
The command in this example returns all call park orbit ranges where no prefix has been assigned to the numbers in the range.

skype/skype-ps/skype/Import-CSAnnouncementFile.md

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ ms.reviewer:
1717
Imports an announcement file to the Announcement service audio library.
1818
This cmdlet was introduced in Lync Server 2010.
1919

20-
21-
2220
## SYNTAX
2321

2422
```
@@ -37,24 +35,18 @@ At that point the New-CsUnassignedNumber or Set-CsUnassignedNumber cmdlet can be
3735

3836
Imported files must be WAV or WMA files.
3937

40-
41-
4238
## EXAMPLES
4339

4440
### -------------------------- EXAMPLE 1 --------------------------
4541
```
4642
47-
$a = Get-Content ".\GreetingFile.wav" -ReadCount 0 -Encoding Byte
43+
$a = [System.IO.File]::ReadAllBytes('.\GreetingFile.wav')
4844
4945
Import-CsAnnouncementFile -Parent ApplicationServer:redmond.litwareinc.com -FileName "WelcomeMessage.wav" -Content $a
5046
```
5147

5248
These commands import an audio file into the Announcement service File Store.
53-
Because audio files must be imported as byte arrays, we first need to call the Get-Content cmdlet to retrieve the audio file as an array of individual bytes.
54-
Get-Content is a Windows PowerShell built-in cmdlet to which we pass the name (including path) of the file we want to use for our announcement.
55-
Next we pass a value of 0 to the ReadCount parameter, meaning we want to read the whole file at once.
56-
We then pass a value of Byte to the Encoding parameter, which tells Get-Content that we want the contents of the file as an array of bytes.
57-
We assign that array to the variable $a.
49+
Because audio files must be imported as byte arrays, we first need to retrieve the audio file as an array of individual bytes. We assign that array to the variable $a.
5850

5951
In the second line we call the Import-CsAnnouncementFile cmdlet to actually import the file.
6052
We pass the service Identity ApplicationServer:redmond.litwareinc.com to the Parent parameter, then we pass a name to the FileName parameter (WelcomeMessage.wav).
@@ -64,23 +56,21 @@ Finally, we pass the variable $a as the value to the Content parameter to read i
6456
### -------------------------- EXAMPLE 2 --------------------------
6557
```
6658
67-
Import-CsAnnouncementFile -Parent ApplicationServer:redmond.litwareinc.com -FileName "WelcomeMessage.wav" -Content (Get-Content ".\GreetingFile.wav" -ReadCount 0 -Encoding Byte)
59+
Import-CsAnnouncementFile -Parent ApplicationServer:redmond.litwareinc.com -FileName "WelcomeMessage.wav" -Content ([System.IO.File]::ReadAllBytes('.\GreetingFile.wav'))
6860
```
6961

70-
Example 2 is identical to Example 1 except that we included the Get-Content command inside parentheses as a value to the Content parameter rather than calling that command on its own and assigning it to a variable.
71-
62+
Example 2 is identical to Example 1 except that we included the command inside parentheses as a value to the Content parameter rather than calling that command on its own and assigning it to a variable.
7263

7364
### -------------------------- EXAMPLE 3 --------------------------
7465
```
7566
76-
Get-Content ".\GreetingFile.wav" -ReadCount 0 -Encoding Byte | Import-CsAnnouncementFile -Parent ApplicationServer:redmond.litwareinc.com -FileName "WelcomeMessage.wav"
67+
[System.IO.File]::ReadAllBytes('.\GreetingFile.wav') | Import-CsAnnouncementFile -Parent ApplicationServer:redmond.litwareinc.com -FileName "WelcomeMessage.wav"
7768
```
7869

7970
Example 3 is yet another variation of Example 1.
80-
The difference in this example is that rather than use the Content parameter, we first call the Get-Content cmdlet, then pipe the results to Import-CsAnnouncementFile.
71+
The difference in this example is that rather than use the Content parameter, we first call the command to read the file, then pipe the results to Import-CsAnnouncementFile.
8172
This is the most reliable way of importing an announcement file from a remote session.
8273

83-
8474
## PARAMETERS
8575

8676
### -Parent
@@ -119,6 +109,8 @@ Accept wildcard characters: False
119109
### -Content
120110
The contents of the audio file as a byte array.
121111
112+
A valid value for this parameter requires you to read the file to a byte-encoded object using the following syntax: `([System.IO.File]::ReadAllBytes('<Path>\<FileName>'))`. You can use this command as the parameter value, or you can write the output to a variable (`$data = [System.IO.File]::ReadAllBytes('<Path>\<FileName>')`) and use the variable as the parameter value (`$data`).
113+
122114
```yaml
123115
Type: Byte[]
124116
Parameter Sets: (All)

skype/skype-ps/skype/Import-CsLisConfiguration.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ ms.reviewer:
1717
Imports an Enterprise Voice Enhanced 9-1-1 (E9-1-1) configuration from a backup file.
1818
This cmdlet was introduced in Lync Server 2010.
1919

20-
21-
2220
## SYNTAX
2321

2422
### ByteInput
@@ -48,11 +46,8 @@ You call the Export-CsLisConfiguration cmdlet to back up your configuration.
4846
Later, you modify the Location property of that wireless access point to Building30/Rooms20-40.
4947
If you then call the Import-CsLisConfiguration cmdlet to restore the backed-up configuration, the location for that WAP will be Building30/Room10 (the location before the backup), but the location for Building30/Rooms20-40 will remain in the location configuration database.
5048

51-
52-
5349
## EXAMPLES
5450

55-
5651
### -------------------------- EXAMPLE 1 --------------------------
5752
```
5853
@@ -61,7 +56,6 @@ Import-CsLisConfiguration -FileName C:\E911Config.bak
6156

6257
This example imports the E9-1-1 configuration from the backup file named E911Config.back to the location configuration database.
6358

64-
6559
### -------------------------- EXAMPLE 2 --------------------------
6660
```
6761
@@ -78,34 +72,25 @@ In line 2 the Import-CsLisConfiguration cmdlet is called.
7872
The ByteInput parameter receives a value of $lisconfig, which is the variable containing the byte array we exported.
7973
This will import that byte array back into the location configuration database.
8074

81-
82-
8375
### -------------------------- EXAMPLE 3 --------------------------
8476
```
8577
8678
$lisconfig = Export-CsLisConfiguration -AsBytes
8779
88-
$listconfig | Set-Content -Path C:\E911Config.bak -Encoding byte
80+
[System.IO.File]::WriteAllBytes('C:\E911Config.bak', $lisconfig)
8981
90-
Get-Content -ReadCount 0 -Encoding byte -Path C:\E911Config.bak | Import-CsLisConfiguration
82+
[System.IO.File]::ReadAllBytes('C:\E911Config.bak') | Import-CsLisConfiguration
9183
```
9284

9385
Example 3 is a more complete version of Example 2.
9486
The first line is the same, we call the Export-CsLisConfiguration cmdlet with the AsBytes parameter to store the LIS configuration as an array of bytes in the variable $lisconfig.
9587
The rest of this example shows how to save that configuration to a file and then import it back into the location configuration database.
9688

97-
In line 2 we pipe the contents of $lisconfig, which is the byte array representing the LIS configuration, to the Windows PowerShell Set-Content cmdlet.
98-
We assign values to two parameters of the Set-Content cmdlet: Path and Encoding.
99-
We assign the full path and file name of the file to which we want to save the configuration to the Path parameter.
100-
We use the Encoding parameter with a value of byte to ensure the configuration is stored as an array of bytes.
89+
In line 2 we pipe the contents of $lisconfig, which is the byte array representing the LIS configuration, to the full path and file name of the file to which we want to save the configuration.
10190

10291
Finally, in line 3 we import the configuration back into the location configuration database.
103-
First we call the Get-Content cmdlet to retrieve the contents from the file.
104-
We pass a value of 0 to the ReadCount property, which tells the Get-Content cmdlet to read all the contents of the file at once rather than one line at a time.
105-
We again use the Encoding parameter with a value of byte to specify what type of data we're reading from the file.
106-
Finally we pass the file name to the Path parameter.
107-
The contents of the file that we read with the Get-Content cmdlet is piped to the Import-CsLisConfiguration cmdlet, which imports the saved configuration into the location configuration database.
108-
92+
First we retrieve the contents from the file.
93+
The contents of the file are then piped to the Import-CsLisConfiguration cmdlet, which imports the saved configuration into the location database.
10994

11095
## PARAMETERS
11196

skype/skype-ps/skype/Import-CsOnlineAudioFile.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,27 @@ The Import-CsOnlineAudioFile cmdlet uploads a new audio file for use with the Au
2828

2929
### Example 1
3030
```powershell
31-
$content = Get-Content "C:\Media\Hello.wav" -Encoding byte -ReadCount 0
31+
$content = [System.IO.File]::ReadAllBytes('C:\Media\Hello.wav')
3232
$audioFile = Import-CsOnlineAudioFile -ApplicationId "OrgAutoAttendant" -FileName "Hello.wav" -Content $content
3333
```
3434

3535
This example creates a new audio file using the WAV content that has a filename of Hello.wav to be used with organizational auto attendants. The stored variable, $audioFile, will be used when running other cmdlets to update the audio file for Auto Attendant, for example [New-CsAutoAttendantPrompt](https://learn.microsoft.com/powershell/module/skype/new-csautoattendantprompt).
3636

3737
### Example 2
3838
```powershell
39-
$content = Get-Content "C:\Media\MOH.wav" -Encoding byte -ReadCount 0
39+
$content = [System.IO.File]::ReadAllBytes('C:\Media\MOH.wav')
4040
$audioFile = Import-CsOnlineAudioFile -ApplicationId "HuntGroup" -FileName "MOH.wav" -Content $content
4141
```
4242

43-
This example creates a new audio file using the WAV content that has a filename of MOH.wav to be used as a Music On Hold file with a Call Queue. The stored variable, $audioFile, will be used with [Set-CsCallQueue](https://learn.microsoft.com/powershell/module/skype/set-cscallqueue) to provide the audio file id.
43+
This example creates a new audio file using the WAV content that has a filename of MOH.wav to be used as a Music On Hold file with a Call Queue. The stored variable, $audioFile, will be used with [Set-CsCallQueue](https://learn.microsoft.com/powershell/module/skype/set-cscallqueue) to provide the audio file id.
4444

4545
### Example 3
4646
```powershell
47-
$content = Get-Content "C:\Media\MOH.wav" -Encoding byte -ReadCount 0
47+
$content = [System.IO.File]::ReadAllBytes('C:\Media\MOH.wav')
4848
$audioFile = Import-CsOnlineAudioFile -ApplicationId TenantGlobal -FileName "MOH.wav" -Content $content
4949
```
5050

51-
This example creates a new audio file using the WAV content that has a filename of MOH.wav to be used as Music On Hold for Microsoft Teams. The stored variable, $audioFile, will be used with [New-CsTeamsCallHoldPolicy](https://learn.microsoft.com/powershell/module/skype/new-csteamscallholdpolicy) to provide the audio file id.
52-
53-
### Example 4
54-
```powershell
55-
$content = Get-Content "C:\Media\MOH.wav" -AsByteStream -ReadCount 0
56-
$audioFile = Import-CsOnlineAudioFile -ApplicationId 'TenantGlobal' -FileName 'MOH.wav' -Content $content
57-
```
58-
59-
This example uses the `-AsByteStream` parameter instead of the `-Encoding byte` parameter. Requires PowerShell 6 and later versions, where `-Encoding byte` is no longer available. The example creates a new audio file using the WAV content that has a filename of MOH.wav to be used as Music On Hold for Microsoft Teams. The stored variable, $audioFile, will be used with [New-CsTeamsCallHoldPolicy](New-CsTeamsCallHoldPolicy.md) to provide the audio file id.
60-
51+
This example creates a new audio file using the WAV content that has a filename of MOH.wav to be used as Music On Hold for Microsoft Teams. The stored variable, $audioFile, will be used with [New-CsTeamsCallHoldPolicy](https://learn.microsoft.com/powershell/module/skype/new-csteamscallholdpolicy) to provide the audio file id.
6152

6253
## PARAMETERS
6354

skype/skype-ps/skype/Import-CsRgsAudioFile.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ ms.reviewer:
1717
Imports a new audio file for use with the Response Group application.
1818
This cmdlet was introduced in Lync Server 2010.
1919

20-
21-
2220
## SYNTAX
2321

2422
```
@@ -37,14 +35,12 @@ Note that you must run Import-CsRgsAudioFile each time you want to use an audio
3735
For example, suppose Workflow A uses a given audio file as its custom music on hold file and you now want to use that same audio file as the custom music on hold for Workflow B.
3836
Even though the audio file is already used by the Response Group application you will still need to import the file in order to use it with Workflow B.
3937

40-
41-
4238
## EXAMPLES
4339

4440
### -------------------------- EXAMPLE 1 --------------------------
4541
```
4642
47-
$x = Import-CsRgsAudioFile -Identity "service:ApplicationServer:atl-cs-001.litwareinc.com" -FileName "WhileYouWait.wav" -Content (Get-Content C:\Media\WhileYouWait.wav -Encoding byte -ReadCount 0)
43+
$x = Import-CsRgsAudioFile -Identity "service:ApplicationServer:atl-cs-001.litwareinc.com" -FileName "WhileYouWait.wav" -Content ([System.IO.File]::ReadAllBytes('C:\Media\WhileYouWait.wav'))
4844
4945
$y = Get-CsRgsWorkflow -Identity "service:ApplicationServer:atl-cs-001.litwareinc.com" -Name "Help Desk Workflow"
5046
@@ -58,16 +54,14 @@ To perform this task, the first command uses Import-CsRgsAudioFile to import the
5854
In addition to the Identity parameter (which specifies the service location) the FileName parameter is used to specify the file name of the file being imported.
5955

6056
At the same time, the Content parameter is used to import the audio file.
61-
File importing is carried out by calling the Get-Content cmdlet followed by the path to the file being imported.
62-
Get-Content also requires you to set the encoding type to byte and the ReadCount to 0.
63-
(Setting the ReadCount to 0 ensures that the entire file is read in a single operation.) The imported file is then stored in a variable named $x.
57+
File importing is carried out by calling the `[System.IO.File]::ReadAllBytes` command with the path to the file being imported.
58+
The imported file is then stored in a variable named $x.
6459

6560
In the second command, Get-CsRgsWorkflow is used to create an object reference ($y) to the workflow Help Desk Workflow.
6661
After this object reference has been created, command 3 sets the value of the CustomMusicOnHoldFile property to $x, the variable containing the imported audio file.
6762
Finally, the last command in the example uses Set-CsRgsWorkflow to write these changes to the actual workflow Help Desk Workflow.
6863
If you do not call Set-CsRgsWorkflow, your modifications will exist only in memory, and will disappear as soon as you close Windows PowerShell or delete the variables $x or $y.
6964

70-
7165
## PARAMETERS
7266

7367
### -Identity
@@ -89,8 +83,8 @@ Accept wildcard characters: False
8983
9084
### -Content
9185
Actual content of the audio file being imported.
92-
The Content property is populated by calling the Get-Content cmdlet.
93-
When calling Get-Content, set the Encoding parameter to byte and the ReadCount parameter to 0 (for details, see the Examples section in this topic).
86+
87+
A valid value for this parameter requires you to read the file to a byte-encoded object using the following syntax: `([System.IO.File]::ReadAllBytes('<Path>\<FileName>'))`. You can use this command as the parameter value, or you can write the output to a variable (`$data = [System.IO.File]::ReadAllBytes('<Path>\<FileName>')`) and use the variable as the parameter value (`$data`).
9488

9589
```yaml
9690
Type: Byte[]

skype/skype-ps/skype/New-CsAutoAttendantPrompt.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This example creates a new prompt that reads the supplied text.
4848

4949
### -------------------------- Example 2 --------------------------
5050
```powershell
51-
$content = Get-Content "C:\Media\hello.wav" -Encoding byte -ReadCount 0
51+
$content = [System.IO.File]::ReadAllBytes('C:\Media\hello.wav')
5252
$audioFile = Import-CsOnlineAudioFile -ApplicationId "OrgAutoAttendant" -FileName "hello.wav" -Content $content
5353
$audioFilePrompt = New-CsAutoAttendantPrompt -AudioFilePrompt $audioFile
5454
```
@@ -57,7 +57,7 @@ This example creates a new prompt that plays the selected audio file.
5757

5858
### -------------------------- Example 3 --------------------------
5959
```powershell
60-
$content = Get-Content "C:\Media\hello.wav" -Encoding byte -ReadCount 0
60+
$content = [System.IO.File]::ReadAllBytes('C:\Media\hello.wav')
6161
$audioFile = Import-CsOnlineAudioFile -ApplicationId "OrgAutoAttendant" -FileName "hello.wav" -Content $content
6262
$dualPrompt = New-CsAutoAttendantPrompt -ActiveType AudioFile -AudioFilePrompt $audioFile -TextToSpeechPrompt "Welcome to Contoso!"
6363
```

skype/skype-ps/skype/New-CsClientPolicy.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,9 +1355,7 @@ To search only last name, first name, and display name you would construct this
13551355
After the binary value has been constructed, it must then be converted to a decimal value before being assigned to SearchPrefixFlags.
13561356
To convert a binary number to a decimal number, you can use the a Windows PowerShell command similar to this:
13571357

1358-
`\[Convert\]::ToInt32("1110111", 2)`
1359-
1360-
1358+
`[Convert]::ToInt32("1110111", 2)`
13611359

13621360
```yaml
13631361
Type: UInt16

0 commit comments

Comments
 (0)