Quantcast
Channel: Outlook IT Pro Discussions Forum
Viewing all articles
Browse latest Browse all 3066

Powershell create outfile and send by email.

$
0
0

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.


Viewing all articles
Browse latest Browse all 3066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>