首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Powershell获取DHCP客户端信息

使用Powershell获取DHCP客户端信息
EN

Stack Overflow用户
提问于 2020-10-10 18:54:45
回答 1查看 5.4K关注 0票数 0

是否可以使用Powershell在庞大的DHCP服务器和作用域列表中找到DHCP客户端?

我在一家医院工作,医院有多个DHCP服务器(每个区域一个),有多个作用域(每个服务器的DHCP范围超过50个)。我试图找到一种方法,可以编写一个Powershell脚本来筛选所有服务器和作用域,并返回我的(手动)服务器退役过程所需的相关信息,而不必手动完成此操作。

我们确实有应用程序和工具(太阳风),可以为我提供我所需要的信息,但这既费时又费时,我宁愿让这个Powershell脚本--一个“一站式商店”脚本来收集我的信息并清理DHCP库存。并最终将其放入整个端到端的进程中,以便对服务器进行退役。我的梦想是能够运行一个脚本,给它一个服务器名,并让进程贯穿并清除从DHCP到DNS到AD用户和计算机的所有内容。但我现在就从小开始。

EN

回答 1

Stack Overflow用户

发布于 2020-10-10 20:06:00

使用示例资源

“PowerShell DHCP”

使用视频教程

“'Youtube管理”

使用内置cmdlet。

代码语言:javascript
复制
Get-Command -Name '*DHCP*' | 
Where-Object -Property Name -like '*scope*' | 
Format-Table -AutoSize
# Results
<#
CommandType Name                                     Version Source    
----------- ----                                     ------- ------    
Function    Add-DhcpServerv4FailoverScope            2.0.0.0 DhcpServer
Function    Add-DhcpServerv4MulticastScope           2.0.0.0 DhcpServer
Function    Add-DhcpServerv4Scope                    2.0.0.0 DhcpServer
Function    Add-DhcpServerv4Superscope               2.0.0.0 DhcpServer
Function    Add-DhcpServerv6Scope                    2.0.0.0 DhcpServer
Function    Get-DhcpServerv4MulticastScope           2.0.0.0 DhcpServer
Function    Get-DhcpServerv4MulticastScopeStatistics 2.0.0.0 DhcpServer
Function    Get-DhcpServerv4Scope                    2.0.0.0 DhcpServer
Function    Get-DhcpServerv4ScopeStatistics          2.0.0.0 DhcpServer
Function    Get-DhcpServerv4Superscope               2.0.0.0 DhcpServer
Function    Get-DhcpServerv4SuperScopeStatistics     2.0.0.0 DhcpServer
Function    Get-DhcpServerv6Scope                    2.0.0.0 DhcpServer
Function    Get-DhcpServerv6ScopeStatistics          2.0.0.0 DhcpServer
Function    Remove-DhcpServerv4FailoverScope         2.0.0.0 DhcpServer
Function    Remove-DhcpServerv4MulticastScope        2.0.0.0 DhcpServer
Function    Remove-DhcpServerv4Scope                 2.0.0.0 DhcpServer
Function    Remove-DhcpServerv4Superscope            2.0.0.0 DhcpServer
Function    Remove-DhcpServerv6Scope                 2.0.0.0 DhcpServer
Function    Rename-DhcpServerv4Superscope            2.0.0.0 DhcpServer
Function    Set-DhcpServerv4MulticastScope           2.0.0.0 DhcpServer
Function    Set-DhcpServerv4Scope                    2.0.0.0 DhcpServer
Function    Set-DhcpServerv6Scope                    2.0.0.0 DhcpServer
#>

使用帮助文件中的示例来开始或完成任务。

代码语言:javascript
复制
# Get specifics for a module, cmdlet, or function
(Get-Command -Name Get-DhcpServerv4Scop).Parameters
(Get-Command -Name Get-DhcpServerv4Scop).Parameters.Keys
Get-help -Name Get-DhcpServerv4Scop -Examples
Get-help -Name Get-DhcpServerv4Scop -Full
Get-help -Name Get-DhcpServerv4Scop -Online

# Find all cmdlets / functions with a target parameter
Get-Command -CommandType Cmdlet |
Where-Object {
    Try {$PSItem.parameters.keys -match 'credential'}
    Catch{} 
}|
Out-GridView -PassThru -Title '
Available cmdlets which has a specific parameter'

Get-Command -CommandType Function |
Where-Object {
    Try {$PSItem.parameters.keys -match 'credential'}
    Catch{} 
}|
Out-GridView -PassThru -Title '
Available functions which has a specific parameter'

# Get property enums/options for a specifc cmdlet/function
(Get-Service | Select-Object -First 1).Status.GetType()
[System.ServiceProcess.ServiceControllerStatus]::
GetNames([System.ServiceProcess.ServiceControllerStatus])

寻找其他可以利用的模块/脚本

代码语言:javascript
复制
Find-Module -Name '*DHCP*' | Format-Table -AutoSize
# Results
<#
Version Name                     Repository Description                                                                                                                  
------- ----                     ---------- -----------                                                                                                                  
2.0.0.0 xDhcpServer              PSGallery  Module with DSC Resources for DHCP Server area                                                                               
1.3     DHCPClient               PSGallery  Sample module for retrieving DHCP client details, based on the script published by Ingmar Verheij at https://www.ingmarver...
1.2.1   DHCPMigration            PSGallery  A module to copy various DHCP information from 1 server to another.                                                          
1.0.0.3 Read-DHCPLogFiles        PSGallery  A small PS module to read DHCP txt logs                                                                                      
1.3     cDhcpServerDynamicUpdate PSGallery  Class based resource to configure DHCP server dynamic updates 
#>

Find-Script -Name '*DHCP*' | Format-Table -AutoSize
# Results
<#
Version Name                               Repository Description                                                                     
------- ----                               ---------- -----------                                                                     
1.0.0   NetIPInterface_EnableDHCP_Config   PSGallery  Enabling DHCP for the IPv4 Address and DNS on the adapter with alias 'Ethernet'.
1.0.0   DnsServerAddress_EnableDHCP_Config PSGallery  Enabling DHCP for the IPv4 Address and DNS on the adapter with alias 'Ethernet'.
#>
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64297104

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档