Powershell - 查询安装了角色的服务器
Powershell - query servers with roles installed
我有一个包含所有服务器名称的 txt 文件。
我想查询txt中的各个服务器是否安装了RDS。到目前为止它工作正常。但是导出需要有服务器名和安装的角色。如何将服务器名传递给输出文件。
目前它正在查询但仅已安装。所以对于 100 台服务器,谁真的可以分辨出哪个服务器安装了它,哪个没有安装>>>>请帮助
Import-Module ServerManager
Get-Content W:\AllWindows.txt | ForEach-Object {Get-WindowsFeature -Name Remote-Desktop-Services} | Format-Table -Auto -wrap | Out-File -FilePath $csvfile
尝试这样的事情:
Get-Content W:\AllWindows.txt | ForEach-Object { @(($_), (Get-WindowsFeature -Name Remote-Desktop-Services)) } | Format-Table -Auto -wrap | Out-File -FilePath $csvfile
我已经解决了:
Get-Content W:\windows2012.csv | Foreach-Object {{Get-WindowsFeature | where-object {$_.Installed -eq $True} | Export-Csv -Path "W:\output$_.txt"}
我有一个包含所有服务器名称的 txt 文件。
我想查询txt中的各个服务器是否安装了RDS。到目前为止它工作正常。但是导出需要有服务器名和安装的角色。如何将服务器名传递给输出文件。 目前它正在查询但仅已安装。所以对于 100 台服务器,谁真的可以分辨出哪个服务器安装了它,哪个没有安装>>>>请帮助
Import-Module ServerManager
Get-Content W:\AllWindows.txt | ForEach-Object {Get-WindowsFeature -Name Remote-Desktop-Services} | Format-Table -Auto -wrap | Out-File -FilePath $csvfile
尝试这样的事情:
Get-Content W:\AllWindows.txt | ForEach-Object { @(($_), (Get-WindowsFeature -Name Remote-Desktop-Services)) } | Format-Table -Auto -wrap | Out-File -FilePath $csvfile
我已经解决了:
Get-Content W:\windows2012.csv | Foreach-Object {{Get-WindowsFeature | where-object {$_.Installed -eq $True} | Export-Csv -Path "W:\output$_.txt"}