问候同伴,
这是我经过长时间潜伏后的第一个问题。我是PowerShell的新手,我目前正在从事的工作之一就是创建一个脚本,该脚本将获取系统信息,映射的驱动器,网络配置等。我希望能够从DirectAccess获取IPv6地址。 IPSec隧道端点并对其执行ping操作。我想请你帮我一下
这是到目前为止我得到的:
##----------------------------------------------------------
## Variables
##----------------------------------------------------------
$Command = {[PSCustomObject]@{
'computerSystem' = get-wmiobject Win32_ComputerSystem
'computerMappedDrives' = Get-WmiObject -Class Win32_MappedLogicalDisk | Select-Object name,providername
'computerEventErrorsApp' = Get-EventLog -LogName Application -EntryType Error -Newest 10 | Select-Object timegenerated,source,message
'computerEventErrorsSys' = Get-EventLog -LogName System -EntryType Error -Newest 10 | Select-Object timegenerated,source,message
'computerDAClient' = Get-DAClientExperienceConfiguration
'computerDAStatus' = Get-DAConnectionStatus
'computerOfflineFiles' = Get-WmiObject -Class win32_OfflineFilesCache
}}
$data = Invoke-Command -ScriptBlock $Command
Logging -Text ("HOSTNAME : " + $env:COMPUTERNAME) -LogFile $logfile
Logging -Text ("USER LOGGED IN : " + $data.computerSystem.UserName) -LogFile $logfile
Logging -Text ("DIRECT ACCESS NAME : " + $data.computerDAClient.FriendlyName) -LogFile $logfile
Logging -Text ("DIRECT ACCESS STATUS : " + $data.computerDAStatus.Status) -LogFile $logfile
Logging -Text ("OFFLINE FILES : " + ($data.computerOfflineFiles | Select-Object Enabled)) -LogFile $logfile
##----------------------------------------------------------
## Network Drives
##----------------------------------------------------------
foreach ($mappeddrive in $data.computerMappedDrives)
{
Logging -Text ("NETWORK DRIVES MAPPED : " + $mappeddrive.name + " -> " + $mappeddrive.providername) -LogFile $logfile
}
Write-Host "-NETWORK DRIVES COLLECTED-" -ForegroundColor Green
这是执行此命令的结果
$data.computerdaclient
Description : DA Client Settings
CorporateResources : {HTTP:http://directaccess-WebProbeHost.xxx, HTTP:http://directaccess-webprobehost.xxx/}
IPsecTunnelEndpoints : {PING:fd51:3db1:xxxx:xxxx::1, PING:fd51:3db1:xxxx:xxxx::2, PING:fd45:4035:xxxx:xxxx::1, PING:fd45:4035:xxxx:xxxx::2}
CustomCommands :
PreferLocalNamesAllowed : True
UserInterface : True
PassiveMode : False
SupportEmail : DA_support@xxxx
FriendlyName : Direct Access
ManualEntryPointSelectionAllowed : True
GslbFqdn :
ForceTunneling : Default
关于如何从IPSecTunnelEndpoint
中提取值并随后执行ping
的任何想法?
预先感谢您!
干杯,
贡萨洛
答案 0 :(得分:0)
我认为我现在已经可以使用它了:
+----+----------+-----------+
| id | group_id | value |
+----+----------+-----------+
| 4 | 1 | -1 |
+----+----------+-----------+
| 5 | 1 | 1 |
+----+----------+-----------+
结果是:
(Get-DAClientExperienceConfiguration).IPsecTunnelEndpoints | ForEach-Object{
If($_ -like '*PING:*'){
$ipsec= $_.replace('PING:','')
Write-Host ("TEST CONNECTION TO: " + $ipsec)
Test-Connection $ipsec
}
}