space character issue in -Path

i tried below script but because there is a space between service and worker it stops the script with error could not find.

if i put quotes it doesn’t take my $USERID entry

Any ideas?

 

$USERID = Read-Host = ‘Provide user ID’

Get-ChildItem -Path C:\Users$USERID\Desktop\service worker\test -Include . -File -Recurse | foreach { $_.Delete()}

Jurg,

you are in the wrong forum. :wink: For general Powershell question you should ask here: https://powershell.org/forums/forum/windows-powershell-qa

You should format your code as code, please. Here you can read how that works: Guide to Posting Code

You should use double quotes for your path if it contains spaces.

 

Get-ChildItem -Path “C:\Users$USERID\Desktop\service worker\test” -Include . -File -Recurse | foreach { $_.Delete()}

To evaluate $USERID, you need double quotes:

Get-ChildItem -Path “C:\Users$USERID\Desktop\service worker\test” -Include . -File -Recurse | foreach { $_.Delete()}

Did you try that?