Use .NET configuration to set defaults for Send-MailMessage.
Use-NetMailConfig.ps1 [[-Scope] <String>] [-Private] [-ProgressAction <ActionPreference>] [<CommonParameters>]
The configuration system provides a place to set email defaults:
<system.net> <mailSettings> <smtp from=”source@example.org” deliveryMethod=”network”> <network host=”mail.example.org” enableSsl=”true” /> </smtp> </mailSettings> </system.net>
The values for Send-MailMessage’s From, SmtpServer, and UseSsl will be taken from whatever is set in the machine.config (or more localized config).
Use-NetMailConfig.ps1
Sets Send-MailMessage defaults for From, SmtpServer, and UseSsl to values from the ConfigurationManager.
The scope to create the defaults in.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: Local
Accept pipeline input: False
Accept wildcard characters: False
Indicates the defaults should not be visible to child scopes.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.