Forum Discussion
Bittu_8148
Feb 01, 2022Copper Contributor
Unable to save the Output to file location
Hi, Please find below code. I am unable to save the Output to file location. I have created the $Filepath to create new folder with year, if it is created it will ignore automatically since I have...
- Feb 01, 2022
You're putting the command to create the folder in a variable, that's one reason. Other reason is the formatting of the file, I changed it a little bit 🙂
New-Item -ItemType Directory -Force -Path "C:\ADComputers\$((Get-Date).tostring("yyyy"))" $Filepath = "C:\ADComputers\$((Get-Date).tostring("yyyy"))" $filename=(Get-Date).tostring("dd-MM-yyyy-hh-mm-ss") Get-ADComputer -Filter * -Property * | Select-Object Name,enabled,OperatingSystem,OperatingSystemVersion,ipv4Address,lastlogondate,CanonicalName | Export-CSV -Path ($Filepath + '\'+ "ÁDComputers_Report_$($filename).csv") -Force -Delimiter ','-NoTypeInformation -Encoding UTF8
Bittu_8148
Feb 02, 2022Copper Contributor
Harm_Veenstra
Thanks for the assistance. It's perfect what I have imagined.
Feb 02, 2022
No problem, please mark the answer as solution 😊