Hey everyone! I'm having trouble running a PowerShell script to export all my Active Directory groups along with their creation dates and times. Here's the script I'm using:
```powershell
Get-ADGroup -Filter * -Properties whenCreated, whenChanged |
Select Name, DistinguishedName, GroupScope, GroupCategory,
@{Name='Created';Expression={$_.whenCreated}},
@{Name='Modified';Expression={$_.whenChanged}},
ObjectGUID |
Export-Csv -Path C:Temp -NoTypeInformation
```
The script seems to run fine until it hits the line to export to CSV, at which point I get an error saying:
```
Export-Csv : Access to the path 'C:Temp' is denied.
```
I've checked the permissions and I have full access to the folder, I'm a domain admin, and I've also started PowerShell as an administrator. Can anyone suggest what else I might check or what I might be doing wrong?
2 Answers
Another option is to use `$env:temp` for the export path. But keep in mind, I prefer using `[System.IO.Path]::GetTempPath()` nowadays for better compatibility across different systems. Just a thought!
It seems like you're trying to save the CSV directly to the Temp folder without specifying a filename. Instead of just `C:Temp`, try using `C:Tempgroups.csv`. This should fix the access issue you're encountering.

Related Questions
How To: Running Codex CLI on Windows with Azure OpenAI
Set Wordpress Featured Image Using Javascript
How To Fix PHP Random Being The Same
Why no WebP Support with Wordpress
Replace Wordpress Cron With Linux Cron
Customize Yoast Canonical URL Programmatically