Reputation: 203
I have a path that looks like this:
$path = path\to\weird\filename\PUBLISERET - Dalager 1, Brøndby - Leveringsaftale D12-24311 1.0.pdf
When I do:
Set-ItemProperty -LiteralPath $path -Name IsReadOnly -Value $true
I tells me that the path doesn't exist even though it does. I believe it is because of the file name. What can I do?
Upvotes: 1
Views: 189
Reputation: 30103
Dmitriy Kapitanov's answer is right: put single quotes around the path. Proof:
PS D:\PShell> $path = 'D:\bat\Unusual Names\Türkçe (Türkiye)\PUBLISERET - Dalager 1, Brøndby - Leveringsaftale D12-24311 1.0.pdf'
PS D:\PShell> Get-ItemProperty $path
Directory: D:\bat\Unusual Names\Türkçe (Türkiye)
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 31.08.2015 17:55 34429 PUBLISERET - Dalager 1, Brøndby - Leveringsaftale
D12-24311 1.0.pdf
PS D:\PShell> Set-ItemProperty -LiteralPath $path -Name IsReadOnly -Value $true
PS D:\PShell> Get-ItemProperty $path
Directory: D:\bat\Unusual Names\Türkçe (Türkiye)
Mode LastWriteTime Length Name
---- ------------- ------ ----
-ar-- 31.08.2015 17:55 34429 PUBLISERET - Dalager 1, Brøndby - Leveringsaftale
D12-24311 1.0.pdf
PS D:\PShell>
Upvotes: 1
Reputation: 41
Try putting single quotes around the path.
$path = 'path\to\weird\filename\PUBLISERET - Dalager 1, Brøndby - Leveringsaftale D12-24311 1.0.pdf'
Upvotes: 2