I have a script that makes changes to a backup .txt file and saves a new .txt that I can use to upload to Cisco Web interface. Using my original script, I would receive an error:
Invalid file uploaded.
This is the original script:
$name = Read-Host 'What is the SX20 name?'
if ($name -notlike "SX20NAME[a-z , 0-9]*")
{
Read-Host 'Please begin naming conventions with "SX20NAME".'
}
else {
$description = Read-Host 'What is the SX20 alias?'
(Get-Content C:\Users\SX20_Backup.txt)|
Foreach-Object {$_-replace 'SX20NAME[a-z , 0-9]*' , $name}|
Foreach-Object {$_-replace 'SetAlias' , $description}|
Out-file $env:USERPROFILE\Desktop\$name.txt}
I added -Encoding UTF8
to the Out-File so that it now looks like this: Out-file $env:USERPROFILE\Desktop\$name.txt -Encoding UTF8}
. So now the interface will accept the file, but I get a new error message:
Some commands were rejected: Volume:"50"
"Volume" happens to be the very first line in the backup file. What can I adjust to resolve this issue?