Reputation: 19
I am getting an error while executing the below. Is the below method to concatenate $env:userprofile with path correct?
$env:userprofile\Documents\DNS\GetDnsRecord.ps1 | ConvertTo-Csv -NoTypeInformation | Select-Object -Skip 1 | Out-File -Append $env:userprofile\Documents\DNS\DnsRecord.csv
Error:
+ $env:userprofile\Documents\DNS\GetDnsRecord.ps1 | ConvertTo-Csv -NoTy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '\Documents\DNS\GetDnsRecord.ps1' in expression or statement.
Thanks for the help
John
Upvotes: 0
Views: 800
Reputation: 135
You might want to read a bit about Join-Path: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/join-path?view=powershell-7
Join-Path $env:userprofile '\Documents\DNS\GetDnsRecord.ps1'
Upvotes: 1