KuganMV
KuganMV

Reputation: 1

Single powershell script?

How can i combine below 3 powershell scripts into one single script?

  1. Delete user
  2. Hide from email address enable in exchange
  3. ActiveSync disable
  4. Export the result in csv

.

Get-content C:\TEMP\Users1.txt |get-aduser |set-aduser -enabled $false
Get-content C:\TEMP\user1.txt | Set-Mailbox -HiddenFromAddressListsEnabled $true
Get-content C:\temp\users1.txt | set-CASMailbox -ActiveSyncEnabled:$False
Export-Csv "DisableU-$(Get-Date -f yyyyMMdd_HHmm).csv" -NoType

Kindly guide me. Thanks in advance.

Upvotes: 0

Views: 236

Answers (1)

gabr
gabr

Reputation: 203

Just put them into any *.ps1 file and run from console by providing the full path to the script. If you are in the script directory just run:

./Script.ps1

You might also need to set proper Execution Policy. This is the separated topic but just for now you can set it to unrestricted.

PS> Set-ExecutionPolicy Unrestricted -Force

But please read about Execution Policies.

Upvotes: 1

Related Questions