🤖 Ai回答: PowerShell provides several cmdlets for working with DNS、Here are some common tasks and corresponding cmdlets:
1、View DNS client settings:
Get-DnsClientServerAddress
2、Set DNS server addresses:
Set-DnsClientServerAddress
3、Flush DNS cache:
Clear-DnsClientCache
4、Resolve DNS names:
Resolve-DnsName
5、View DNS zone information (requires DNS server role):
Get-DnsServerZone
6、Add a DNS record:
Add-DnsServerResourceRecord
7、Remove a DNS record:
Remove-DnsServerResourceRecord
8、Modify DNS zone properties:
Set-DnsServerZone
9、Export DNS zone data:
Export-DnsServerZone
10、Import DNS zone data:
Import-DnsServerZone
Here are some examples of how to use these cmdlets:
1、View current DNS server addresses for all network adapters:
Get-DnsClientServerAddress | Format-Table -Property InterfaceAlias, ServerAddresses
2、Set DNS server addresses for a specific network adapter:
Set-DnsClientServerAddress -InterfaceAlias Ethernet -ServerAddresses (8.8.8.8, 8.8.4.4)
3、Flush DNS cache:
Clear-DnsClientCache
4、Resolve a DNS name:
Resolve-DnsName -Name www.65.hk
5、List all DNS zones on a DNS server:
Get-DnsServerZone
Remember that some of these cmdlets require the DNS Server role to be installed on the machine where you're running the commands、Also, you may need appropriate permissions to execute certain commands, especially those that modify DNS settings.