1.
I want powershell automatical create an outfile, to do this I have this script.
Search-ADAccount -AccountExpiring -TimeSpan "365" -UsersOnly | Get-ADUser -Prop samAccountName,Description,AccountExpirationDate | Select-Object Name,samAccountName,Description,AccountExpirationDate | Sort-Object AccountExpirationDate | Format-Table * -AutoSize | Out-File C:\SendMailPowerShell\GuestAccounts.txt -Width 500
But when I try to run the ps1 file via a batch file this file won't create anything.
2.
After the file is create I would like powershell to send the file to a specific mailaddress. But I need that powershell creates my outfile before it tries to send it.
How can I achieve this? I do not have the possibility to use QAD within powershell i my enviroment.