Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exchange Shell Scripts

Status
Not open for further replies.

baggies1

IS-IT--Management
Oct 28, 2009
33
GB
Hi

I currently use several seperate commands to update the whitelist on both senderid and contentfilter spam filters on Edge server (ex2007).

Goes a little something like this:

$List = (Get-ContentFilterConfig).BypassedSenderDomains
$list - to display list of variables
$List.add("microsoft.com”)
$list - to check list of variables
set-contentfilterconfig -BypassedSenderDomains:$list
get-contentfilterconfig - to check new entries

I do it this way to avoid overwriting existing entries in this field. This process in essence updates the existing list of whitelist entries whilst adding my new entry.

I want to create a script that does the above automatically, either by prompting for the new entry/domain or by putting it into a adjoining text file where it can be read.

Any ideas or pointers would be great thanks.
 
If you have it in a .ps1 file, then you can use $Args[0] to get the first thing supplied on the command line. So this should work, but I haven't tested it:

[script PowerShell]
$List = (Get-ContentFilterConfig).BypassedSenderDomains $list
$List.add($args[0])
$list
set-contentfilterconfig -BypassedSenderDomains:$list
get-contentfilterconfig
[/script]

And you would just call it via
.\Add-Domain.ps1 microsoft.com
(or whatever your script is called)

This would add microsoft.com to the list.

Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.
 
You should also be able to do this, which would prompt for a name to add:

Code:
$a = read-host -prompt "Please enter domain name to add: "
$list = (Get-ContentFilterConfig).BypassedSenderDomains
$list
$list.add($a) 
$list
set-contentfilterconfig -BypassedSenderDomains:$list 
get-contentfilterconfig

Pat Richard MVP
Plan for performance, and capacity takes care of itself. Plan for capacity, and suffer poor performance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top