SOLVED

Get-AzureStorageFileContent not working in script

Copper Contributor

Hi, I need help with one thing because I am writing a script that will download one file from Azure File Sever. Unfortunately, I cannot find the problem and the cause of the errors. When I run the script without saving, i.e. line by line in powershell, it works fine. Unfortunately, when I save the script to a file and call it from Powershell, it bursts with errors. Does anyone have any idea what this is caused by.

Zrzut ekranu 2022-05-13 094453.pngZrzut ekranu 2022-05-13 094518.png

2 Replies
best response confirmed by Rakkos_SSW (Copper Contributor)
Solution

@Rakkos_SSW 

 

My uneducated guess is the script file is saved in a Unicode format that presents issues when called from your PowerShell session, which I'm further guessing is running under a different culture.

 

Because I'm a Skippy - sorry, Australian - I'm not terribly familiar with other culture settings but something you could try is re-saving the .ps1 script in Notepad as either ASCII or UTF-8 and then running that. It might also pay to delete the existing hyphens first and re-typing them while in Notepad before re-saving the script (but again, this is also just another guess - cultures really aren't my strength.)

 

It's a long shot and I'm 100% guessing, but the fact that both hyphens in front of each parameter within the red error message have translated to a different Unicode character is what has me guessing in this direction.

 

Cheers,

Lain

@LainRobertson 

Thanks, when i save in Notepadd using UTF-8 BOM working fine 🙂

1 best response

Accepted Solutions
best response confirmed by Rakkos_SSW (Copper Contributor)
Solution

@Rakkos_SSW 

 

My uneducated guess is the script file is saved in a Unicode format that presents issues when called from your PowerShell session, which I'm further guessing is running under a different culture.

 

Because I'm a Skippy - sorry, Australian - I'm not terribly familiar with other culture settings but something you could try is re-saving the .ps1 script in Notepad as either ASCII or UTF-8 and then running that. It might also pay to delete the existing hyphens first and re-typing them while in Notepad before re-saving the script (but again, this is also just another guess - cultures really aren't my strength.)

 

It's a long shot and I'm 100% guessing, but the fact that both hyphens in front of each parameter within the red error message have translated to a different Unicode character is what has me guessing in this direction.

 

Cheers,

Lain

View solution in original post