Powershell Results to TXT file

Copper Contributor

Powershell newbie here......looking to run the following but want to send the output to a text file.  


Get-SPOSite -Template REDIRECTSITE#0


I tried adding | Out-File -FilePath C:\somefilename.txt


But that didn't work.  Tells me access to the file path is denied.  


Any help would be much appreciated!  Thank you!

2 Replies
best response confirmed by Stacy Plante (Copper Contributor)
Likely the issue is you’re writing to a file in the root of your C drive. That’s generally not allowed unless you are running PowerShell as a local admin. Try another location like your user folder.
You are exactly right......when I chose a location under my user folder it worked. THANK YOU!