本文整理汇总了C#中System.Management.Automation.Runspaces.Command.addParam方法的典型用法代码示例。如果您正苦于以下问题:C# Command.addParam方法的具体用法?C# Command.addParam怎么用?C# Command.addParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Management.Automation.Runspaces.Command
的用法示例。
在下文中一共展示了Command.addParam方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update_DnsServerResourceRecordSOA
public static void Update_DnsServerResourceRecordSOA(this PowerShellHelper ps, string zoneName,
TimeSpan ExpireLimit, TimeSpan MinimumTimeToLive, string PrimaryServer,
TimeSpan RefreshInterval, string ResponsiblePerson, TimeSpan RetryDelay,
string PSComputerName)
{
var cmd = new Command("Get-DnsServerResourceRecord");
cmd.addParam("ZoneName", zoneName);
cmd.addParam("RRType", "SOA");
Collection<PSObject> soaRecords = ps.RunPipeline(cmd);
if (soaRecords.Count < 1)
return;
PSObject oldSOARecord = soaRecords[0];
PSObject newSOARecord = oldSOARecord.Copy();
CimInstance recordData = newSOARecord.Properties["RecordData"].Value as CimInstance;
if (recordData==null) return;
if (ExpireLimit!=null)
recordData.CimInstanceProperties["ExpireLimit"].Value = ExpireLimit;
if (MinimumTimeToLive!=null)
recordData.CimInstanceProperties["MinimumTimeToLive"].Value = MinimumTimeToLive;
if (PrimaryServer!=null)
recordData.CimInstanceProperties["PrimaryServer"].Value = PrimaryServer;
if (RefreshInterval!=null)
recordData.CimInstanceProperties["RefreshInterval"].Value = RefreshInterval;
if (ResponsiblePerson!=null)
recordData.CimInstanceProperties["ResponsiblePerson"].Value = ResponsiblePerson;
if (RetryDelay!=null)
recordData.CimInstanceProperties["RetryDelay"].Value = RetryDelay;
if (PSComputerName!=null)
recordData.CimInstanceProperties["PSComputerName"].Value = PSComputerName;
UInt32 serialNumber = (UInt32)recordData.CimInstanceProperties["SerialNumber"].Value;
// update record's serial number
string sn = serialNumber.ToString();
string todayDate = DateTime.Now.ToString("yyyyMMdd");
if (sn.Length < 10 || !sn.StartsWith(todayDate))
{
// build a new serial number
sn = todayDate + "01";
serialNumber = UInt32.Parse(sn);
}
else
{
// just increment serial number
serialNumber += 1;
}
recordData.CimInstanceProperties["SerialNumber"].Value = serialNumber;
cmd = new Command("Set-DnsServerResourceRecord");
cmd.addParam("NewInputObject", newSOARecord);
cmd.addParam("OldInputObject", oldSOARecord);
cmd.addParam("Zone", zoneName);
ps.RunPipeline(cmd);
}
示例2: Remove_DnsServerResourceRecord
public static void Remove_DnsServerResourceRecord( this PowerShellHelper ps, string zoneName, DnsRecord record)
{
string type;
if (!RecordTypes.rrTypeFromRecord.TryGetValue(record.RecordType, out type))
throw new Exception( "Unknown record type" );
string Name = record.RecordName;
if (String.IsNullOrEmpty(Name)) Name = "@";
var cmd = new Command("Get-DnsServerResourceRecord");
cmd.addParam("ZoneName", zoneName);
cmd.addParam("Name", Name);
cmd.addParam("RRType", type);
Collection<PSObject> resourceRecords = ps.RunPipeline(cmd);
object inputObject = null;
foreach (PSObject resourceRecord in resourceRecords)
{
DnsRecord dnsResourceRecord = resourceRecord.asDnsRecord(zoneName);
bool found = false;
switch(dnsResourceRecord.RecordType)
{
case DnsRecordType.A:
case DnsRecordType.AAAA:
case DnsRecordType.CNAME:
case DnsRecordType.NS:
case DnsRecordType.TXT:
found = dnsResourceRecord.RecordData == record.RecordData;
break;
case DnsRecordType.SOA:
found = true;
break;
case DnsRecordType.MX:
found = (dnsResourceRecord.RecordData == record.RecordData) && (dnsResourceRecord.MxPriority == record.MxPriority);
break;
case DnsRecordType.SRV:
found = (dnsResourceRecord.RecordData == record.RecordData)
&&(dnsResourceRecord.SrvPriority == record.SrvPriority)
&&(dnsResourceRecord.SrvWeight == record.SrvWeight)
&&(dnsResourceRecord.SrvPort == record.SrvPort);
break;
}
if (found)
{
inputObject = resourceRecord;
break;
}
}
cmd = new Command( "Remove-DnsServerResourceRecord" );
cmd.addParam( "ZoneName", zoneName );
cmd.addParam("InputObject", inputObject);
cmd.addParam( "Force" );
ps.RunPipeline( cmd );
}
示例3: Remove_DnsServerResourceRecords
public static void Remove_DnsServerResourceRecords(this PowerShellHelper ps, string zoneName, string type)
{
var cmd = new Command("Get-DnsServerResourceRecord");
cmd.addParam("ZoneName", zoneName);
cmd.addParam("RRType", type);
Collection<PSObject> resourceRecords = ps.RunPipeline(cmd);
foreach (PSObject resourceRecord in resourceRecords)
{
cmd = new Command("Remove-DnsServerResourceRecord");
cmd.addParam("ZoneName", zoneName);
cmd.addParam("InputObject", resourceRecord);
cmd.addParam("Force");
ps.RunPipeline(cmd);
}
}
示例4: Add_DnsServerResourceRecordTXT
public static void Add_DnsServerResourceRecordTXT( this PowerShellHelper ps, string zoneName, string Name, string txt )
{
var cmd = new Command( "Add-DnsServerResourceRecord" );
cmd.addParam( "ZoneName", zoneName );
cmd.addParam( "Name", Name );
cmd.addParam( "Txt" );
cmd.addParam( "DescriptiveText", txt );
ps.RunPipeline( cmd );
}
示例5: Add_DnsServerResourceRecordSRV
public static void Add_DnsServerResourceRecordSRV( this PowerShellHelper ps, string zoneName, string Name, string DomainName, UInt16 Port, UInt16 Priority, UInt16 Weight )
{
var cmd = new Command( "Add-DnsServerResourceRecord" );
cmd.addParam( "ZoneName", zoneName );
cmd.addParam( "Name", Name );
cmd.addParam( "Srv" );
cmd.addParam( "DomainName", DomainName );
cmd.addParam( "Port", Port );
cmd.addParam( "Priority", Priority );
cmd.addParam( "Weight", Weight );
ps.RunPipeline( cmd );
}
示例6: Add_DnsServerResourceRecordMX
public static void Add_DnsServerResourceRecordMX( this PowerShellHelper ps, string zoneName, string Name, string mx, UInt16 pref )
{
var cmd = new Command( "Add-DnsServerResourceRecordMX" );
cmd.addParam( "ZoneName", zoneName );
cmd.addParam( "Name", Name );
cmd.addParam( "MailExchange", mx );
cmd.addParam( "Preference", pref );
ps.RunPipeline( cmd );
}
示例7: Add_DnsServerResourceRecordNS
public static void Add_DnsServerResourceRecordNS( this PowerShellHelper ps, string zoneName, string Name, string NameServer )
{
var cmd = new Command( "Add-DnsServerResourceRecord" );
cmd.addParam( "ZoneName", zoneName );
cmd.addParam( "Name", Name );
cmd.addParam( "NS" );
cmd.addParam( "NameServer", NameServer );
ps.RunPipeline( cmd );
}
示例8: Add_DnsServerResourceRecordCName
public static void Add_DnsServerResourceRecordCName( this PowerShellHelper ps, string zoneName, string Name, string alias )
{
var cmd = new Command( "Add-DnsServerResourceRecordCName" );
cmd.addParam( "ZoneName", zoneName );
cmd.addParam( "Name", Name );
cmd.addParam( "HostNameAlias", alias );
ps.RunPipeline( cmd );
}
示例9: Add_DnsServerResourceRecordAAAA
public static void Add_DnsServerResourceRecordAAAA( this PowerShellHelper ps, string zoneName, string Name, string address )
{
var cmd = new Command( "Add-DnsServerResourceRecordAAAA" );
cmd.addParam( "ZoneName", zoneName );
cmd.addParam( "Name", Name );
cmd.addParam( "IPv6Address", address );
ps.RunPipeline( cmd );
}
示例10: Remove_DnsServerZone
public static void Remove_DnsServerZone( this PowerShellHelper ps, string zoneName )
{
var cmd = new Command( "Remove-DnsServerZone" );
cmd.addParam( "Name", zoneName );
cmd.addParam( "Force" );
ps.RunPipeline( cmd );
}
示例11: Add_DnsServerSecondaryZone
/// <summary>Call Add-DnsServerSecondaryZone cmdlet</summary>
/// <param name="ps"></param>
/// <param name="zoneName">a name of a zone</param>
/// <param name="masterServers">an array of IP addresses of the master servers of the zone. You can use both IPv4 and IPv6.</param>
public static void Add_DnsServerSecondaryZone( this PowerShellHelper ps, string zoneName, string[] masterServers )
{
// Add-DnsServerSecondaryZone -Name zzz.com -ZoneFile zzz.com.dns -MasterServers ...
var cmd = new Command( "Add-DnsServerSecondaryZone" );
cmd.addParam( "Name", zoneName );
cmd.addParam( "ZoneFile", zoneName + ".dns" );
cmd.addParam( "MasterServers", masterServers );
ps.RunPipeline( cmd );
}
示例12: Add_DnsServerPrimaryZone
/* public enum eReplicationScope: byte
{
Custom, Domain, Forest, Legacy
} */
/// <summary></summary>
/// <param name="ps"></param>
/// <param name="zoneName"></param>
/// <param name="replicationScope">Specifies a partition on which to store an Active Directory-integrated zone.</param>
/// <returns></returns>
public static void Add_DnsServerPrimaryZone( this PowerShellHelper ps, string zoneName, string[] secondaryServers )
{
Log.WriteStart( "Add_DnsServerPrimaryZone {0} {{{1}}}", zoneName, String.Join( ", ", secondaryServers ) );
// Add-DnsServerPrimaryZone -Name zzz.com -ZoneFile zzz.com.dns
var cmd = new Command( "Add-DnsServerPrimaryZone" );
cmd.addParam( "Name", zoneName );
cmd.addParam( "ZoneFile", zoneName + ".dns" );
ps.RunPipeline( cmd );
// Set-DnsServerPrimaryZone -Name zzz.com -SecureSecondaries ... -Notify ... Servers ..
cmd = new Command( "Set-DnsServerPrimaryZone" );
cmd.addParam( "Name", zoneName );
if( secondaryServers == null || secondaryServers.Length == 0 )
{
// transfers are not allowed
// inParams2[ "SecureSecondaries" ] = 3;
// inParams2[ "Notify" ] = 0;
cmd.addParam( "SecureSecondaries", "NoTransfer" );
cmd.addParam( "Notify", "NoNotify" );
}
else if( secondaryServers.Length == 1 && secondaryServers[ 0 ] == "*" )
{
// allowed transfer from all servers
// inParams2[ "SecureSecondaries" ] = 0;
// inParams2[ "Notify" ] = 1;
cmd.addParam( "SecureSecondaries", "TransferAnyServer" );
cmd.addParam( "Notify", "Notify" );
}
else
{
// allowed transfer from specified servers
// inParams2[ "SecureSecondaries" ] = 2;
// inParams2[ "SecondaryServers" ] = secondaryServers;
// inParams2[ "NotifyServers" ] = secondaryServers;
// inParams2[ "Notify" ] = 2;
cmd.addParam( "SecureSecondaries", "TransferToSecureServers" );
cmd.addParam( "Notify", "NotifyServers" );
cmd.addParam( "SecondaryServers", secondaryServers );
cmd.addParam( "NotifyServers", secondaryServers );
}
ps.RunPipeline( cmd );
Log.WriteEnd( "Add_DnsServerPrimaryZone" );
}