SOLVED

Script to create a text file

Copper Contributor

All,

I am looking to run the below one liner and have it create a txt file on the currently logged in user's desktop. When it runs an error is returned. Any suggestions on how to resolve the error would be appreciated.

The command is below

 get-netipaddress | format-table > $env:userprofile + '\Desktop\info.txt'

 

The error is below

out-file : Access to the path 'C:\Users\my_user_id' is denied.
At line:1 char:1

 

 

I appreciate the response in advance.

 

Keith

1 Reply
best response confirmed by Keith732 (Copper Contributor)
Solution

Try using some bracketing:

 

get-netipaddress | format-table > $($env:userprofile + '\Desktop\info.txt')

 

You should also avoid using Format-Table when writing/exporting to a file.

 

1 best response

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

Try using some bracketing:

 

get-netipaddress | format-table > $($env:userprofile + '\Desktop\info.txt')

 

You should also avoid using Format-Table when writing/exporting to a file.

 

View solution in original post