B
B
Boris Animal2017-09-23 19:16:12
PowerShell
Boris Animal, 2017-09-23 19:16:12

PowerShell script not working. Where is the mistake?

What's wrong? I did everything, as in the example from one site. I do not understand.
And in general, the script from the file is somehow strangely launched. First displays the contents of the file, and then the result. I work from under Visual Studio Code.

[string]$file = Get-Item C:\Windows\explorer.exe
"Размер файла $file составляет $($file.Length) байт"
"Размер: {0:n3} мегабайт" -f ($file.Length / 1mb)

F:\Programming\PowerShell\TextFormat.ps1:8 char:17
+ "P P°P·RјPµSЂ S„P°P#P»P° $file SЃPsSЃS‚P°PIR»SЏPµS‚ $($file.Length) P ...
+ ~~~~~~~~
Unexpected token "P°P#P"P°" in expression or statement.
F:\Programming\PowerShell\TextFormat.ps1:9 char:39
+ "P P° P·PјPµСЂ: {0:n3} PјPµPіR°P±P°P#C‚" -f ($file.Length / 1mb)
+ ~~~~~~~~~~~~~~~~~~~ ~~~~~~
The string is missing a trailing character: ".

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
azarij, 2017-09-23
@Casper-SC

уберите [string] с $file
$file = get-item c:\windows\explorer.exe
"file size of $(file.name) is $($file.length) byte"
...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question