How check communication between two another interface different than data?
For example I want check communication TCP between two voice interfaces. NOT Ping.
Source IP is 10.116.69.215
Destination IP is 10.104.74.145
Previosly I tried:
Test-NetConnection -Port 5060 -ComputerName 10.104.74.145
But I receive only summary from interface data.
ComputerName : 10.104.74.145
RemoteAddress : 10.104.74.145
RemotePort : 5060
InterfaceAlias : VMAccess
SourceAddress : 10.116.64.202
PingSucceeded : False
PingReplyDetails (RTT) : 0 ms
TcpTestSucceeded : False
I tried modify cmdlet. So I began from
Get-NetAdapter
Name InterfaceDescription ifIndex Status
---- -------------------- ------- ------
BackupNet Microsoft Hyper-V Network Adapter #3 15 Up
VoiceNet Microsoft Hyper-V Network Adapter #4 17 Up
VMAccess Microsoft Hyper-V Network Adapter #2 14 Up
BootNet Microsoft Hyper-V Network Adapter 13 Not Present
Test-NetConnection 10.104.74.145 -Port 5060 -ConstrainInterface 17 -DiagnoseRouting -InformationLevel Detailed
but I receive:
Test-NetConnection : A parameter cannot be found that matches parameter name 'ConstrainInterface'.
At line:1 char:45
+ ... st-netconnection 10.102.73.135 -Port 5060 -ConstrainInterface 17 -Dia ...
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Test-NetConnection], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Test-NetConnection
What's wrong?
Can't use -port with that parameter set.
Test-NetConnection
[[-ComputerName] <String>]
[-DiagnoseRouting]
[-ConstrainSourceAddress <String>]
[-ConstrainInterface <UInt32>]
[-InformationLevel <String>]
[<CommonParameters>]
Related
I'm working on a simple cleanup script for work which should include gpupdate. What I want to do is run gpupdate and capture the output or run it in another window and keep the current window on top. I've tried multiple different ways to run gpupdate.exe (including using WSH with the different focus options) but it always pops up in front of the current PowerShell window. PS commandlet Invoke-GPUpdate presents an error "Access is denied" so that doesn't seem to be a usable solution. I'm currently trying to call the ProcessGPUpdate API but I must have something wrong with my code. I don't really like this solution anyway as it doesn't look like it will give feedback/progress.
Reference API: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/wmi_v2/class-library/remotegpupdate-processgpupdate-method-string-boolean-boolean-boolean-boolean-uint32-string-microsoft-grouppolicy
My current non-working code
Add-Type '#
using Microsoft.GroupPolicy;
public static void ProcessGPUpdate(
string Computer,
bool force,
bool boot,
bool logoff,
bool sync,
uint delayInMinutes,
string target
)
'#
I'm open to suggestions on how to accomplish this. Currently, I'm considering running gpupdate minimized.
Edit:
Added command output as requested
PS H:\> $gpupdate = Start-Job -ScriptBlock { gpupdate.exe 2>$1 }
PS H:\> get-job
Id Name PSJobTypeName State HasMoreData
Location Command
-- ---- ------------- ----- -----------
-------- -------
1 Job1 BackgroundJob Failed False
localhost gpupdate.exe 2>$1
PS H:\> Receive-Job -Name Job1
[localhost] The background process reported an error with the following
message: .
+ CategoryInfo : OpenError: (localhost:String) [],
PSRemotingTransportException
+ FullyQualifiedErrorId : 2100,PSSessionStateBroken
PS H:\> $gpupdate = Start-Job -ScriptBlock { gpupdate.exe 2>$1 } -Name
gpupdate
PS H:\> Receive-Job -Name gpupdate
[localhost] The background process reported an error with the following
message: .
+ CategoryInfo : OpenError: (localhost:String) [],
PSRemotingTransportException
+ FullyQualifiedErrorId : 2100,PSSessionStateBroken
PS H:\> $gpupdate = Start-Job -ScriptBlock { & "gpupdate.exe 2>$1" } -Name
gpupdate
PS H:\> Receive-Job -Name gpupdate
[localhost] The background process reported an error with the following
message: .
+ CategoryInfo : OpenError: (localhost:String) [],
PSRemotingTransportException
+ FullyQualifiedErrorId : 2100,PSSessionStateBroken
[localhost] The background process reported an error with the following
message: .
+ CategoryInfo : OpenError: (localhost:String) [],
PSRemotingTransportException
+ FullyQualifiedErrorId : 2100,PSSessionStateBroken
PS H:\> get-job
Id Name PSJobTypeName State HasMoreData
Location Command
-- ---- ------------- ----- -----------
-------- -------
1 Job1 BackgroundJob Failed False
localhost gpupdate.exe 2>$1
3 gpupdate BackgroundJob Failed False
localhost gpupdate.exe 2>$1
5 gpupdate BackgroundJob Failed False
localhost & "gpupdate.exe 2>$1"
I'm trying to configure the Application Pool of WsusPool, on a MS WSUS setup, to raise the Failure Rapid-Fail Protection Interval from 5 minutes to 30 minutes as an administrator using PowerShell.
I'm able to get the setting using
Install-WindowsFeature Web-Mgmt-Console
Import-Module WebAdministration
$WsusPool = Get-Item IIS:\AppPools\WsusPool\
$WsusPool.failure.rapidFailProtectionInterval
Days : 0
Hours : 0
Minutes : 5
Seconds : 0
Milliseconds : 0
Ticks : 3000000000
TotalDays : 0.00347222222222222
TotalHours : 0.0833333333333333
TotalMinutes : 5
TotalSeconds : 300
TotalMilliseconds : 300000
But I get an error when I try save a change to the value
$WsusPool.failure.rapidFailProtectionInterval = New-TimeSpan -Minutes 30
$WsusPool | Set-Item
Set-Item : Specified cast is not valid.
At line:1 char:13
+ $WsusPool | Set-Item
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Item], InvalidCastException
+ FullyQualifiedErrorId : path,Microsoft.PowerShell.Commands.SetItemCommand
Some data of the system:
Version of PowerShell:
PS C:\Windows\system32> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 1 17763 1490
Operating system:
PS C:\Windows\system32> Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, ServicePackMajorVersion, OSArchitecture, WindowsDirectory
Caption : Microsoft Windows Server 2019 Standard
Version : 10.0.17763
ServicePackMajorVersion : 0
OSArchitecture : 64-bit
WindowsDirectory : C:\Windows
You can use Set-WebConfigurationProperty like this
Set-WebConfigurationProperty '//*[#name="WsusPool"]//failure' -Name rapidFailProtectionInterval -Value (New-TimeSpan -Minutes 30)
Here is a very helpful page on the subject
I know this is already answered but I had to dig deep in further and found this link where Michael Felkin has put together extensive property settings for IIS which I found marvelous. Kudo to him for doing that...
You can find all that info here
Here is the shorter version of that I used:
$appPool = New-Item "IIS:\AppPools\MyAppPools" -Force
$appPool.failure.rapidFailProtection = "False"
$appPool | set-item
Keep in mind that the last line is crucial here in order to set the changes.
Hope, someone will find it helpful! :)
PS C:\Windows\system32> Test-WSMan x.x.xx.x
Test-WSMan : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="995" Machine="desktop-12"><f:Message>WS-Management cannot process the request. The operation
failed because of an HTTP error. The HTTP error (12152) is: The server returned an invalid or unrecognized response . </f:Message></f:WSManFault>
At line:1 char:1
+ Test-WSMan x.x.xx.x
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (x.x.xx.x:String) [Test-WSMan], InvalidOperationException
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.TestWSManCommand
I am failing to execute command from this laptop only. RDP connectivity is succeed on this laptop.
Below are output from some commands
PS C:\Windows\system32> winrm get winrm/config/service/auth
Auth
Basic = false
Kerberos = true
Negotiate = true
Certificate = false
CredSSP = false
CbtHardeningLevel = Relaxed
PS C:\Windows\system32> Get-NetConnectionProfile
Name : Unidentified network
InterfaceAlias : Ethernet 2
InterfaceIndex : 8
NetworkCategory : Public
IPv4Connectivity : NoTraffic
IPv6Connectivity : NoTraffic
Name : K32806
InterfaceAlias : Wi-Fi
InterfaceIndex : 17
NetworkCategory : Public
IPv4Connectivity : Internet
IPv6Connectivity : NoTraffic
PS C:\Windows\system32> Get-Item wsman:\localhost\client\trustedhosts
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Client
Type Name SourceOfValue Value
---- ---- ------------- -----
System.String TrustedHosts x.x.xx.x
I have enabled Enable-PSRemoting -force, Restart-Service WinRM and tried Test-WSMan but not luck.Please help me to solve this problem.
Make sure your host is accessible from local machine and is not in private network if it is in private vpn connection will required.
Verify Host Ip is correct
I'm new to powershell and I'm trying to automate creating a DHCP reservation.
So far I'm able to get the IP address like so:
$IP = ( GEt-VM -ComputerName $HVCOMPUTERNAME -VMName $HVNAME | Get-VMNetworkAdapter).IpAddresses[0]
This returns a string like:
192.0.2.1
However, the Add-DhcpServer4Resrvation cmdlet does not accept an ip address as a string. It requires the IP address be a 'System.Net.IpAddress'
Add-DhcpServerv4Reservation -ComputerName $DHCPServer -ScopeId $DHCPScope -IPAddress $IP -Client
Id $MacAddress -Name $HVNAME
Add-DhcpServerv4Reservation : Cannot process argument transformation on parameter 'IPAddress'. Cannot convert value "
10.254.130.104
" to type "System.Net.IPAddress". Error: "An invalid IP address was specified."
At line:1 char:86
+ ... ope -IPAddress $IP -ClientId $MacAddress -Name $HVNAME
+ ~~~
+ CategoryInfo : InvalidData: (:) [Add-DhcpServerv4Reservation], ParameterBindingArgumentTransformationEx
ception
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DhcpServerv4Reservation
How do you convert a string to a System,.Net.IPAddress?
According to this link, it should be easy like
> [ipaddress]"192.0.2.1"
However that doesn't work.
PS C:\Windows\system32> $FOO = [IPAddress]$IP
Cannot convert value "
10.254.130.104
" to type "System.Net.IPAddress". Error: "An invalid IP address was specified."
At line:1 char:1
+ $FOO = [IPAddress]$IP
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvalidCastParseTargetInvocation
tworkAdapter) Format-List -Property *.254.13༁爼ሂÌGEt-VM -ComputerName $HVCOMPUTERNAME -VMName $HVNAME | Get-VMNetworkAdapter) | Format-List -Property * {༁牎ᐂÊGEt-VM -ComputerName $HVCOMPUTERNAME -VMName $HVNAME | Get-VMNetworkAdapter | Format-List -Property *
ఁ牘ࠂÆ$IP = ( GEt-VM -ComputerName $HVCOMPUTERNAME -VMName $HVNAME | Gt-VMNex뿰bpte
Related question
Powershell, get ip4v address of VM
[IPAddress] Wont work if there are spaces in the string
Remove them with Trim()
$IP = [IPAddress]$IP.Trim()
A completely different approach for obtaining IP Address of a server is:
by passing the Workstation/Server name as a parameter to the input type System.Net.DNS cast
For example, if the FQDN name of the host is ABCTest-DEV, then the following script will reveal the IP address of ABCTest-Dev provided, the host has a DNS record already available in the domain.
$ipaddr = [System.Net.Dns]::GetHostAddresses('ABCTest-Dev')|Where AddressFamily -EQ 'InterNetwork'
Write-Host 'This IPV4 Address of the Host is: '$ipaddr
I like to know if there is a way to use PowerShell with WMI to set the MSNdis_currentPacketFilter
PS > Get-WmiObject -class "MSNdis_CurrentPacketFilter" -NameSpace "root\WMI" -Filter "InstanceName='Intel(R) Ethernet Server Adapter I350-T2'"
__GENUS : 2
__CLASS : MSNdis_CurrentPacketFilter
__SUPERCLASS : MSNdis
__DYNASTY : MSNdis
__RELPATH : MSNdis_CurrentPacketFilter.InstanceName="Intel(R) Ethernet Server Adapter I350-T2"
__PROPERTY_COUNT : 3
__DERIVATION : {MSNdis}
__SERVER : HYPERV88
__NAMESPACE : root\WMI
__PATH : \\HYPERV88\root\WMI:MSNdis_CurrentPacketFilter.InstanceName="Intel(R) Ethernet Server Adapter
I350-T2"
Active : True
InstanceName : Intel(R) Ethernet Server Adapter I350-T2
NdisCurrentPacketFilter : 15
PSComputerName : HYPERV88
And I would like to change the NdisCurrentPacketFilter value from 15 to 47.
I tried
Set-WMIInstance -Path ... -Arguments #{NdisCurrentPacketFilter=47}
But, got error. Thanks in advance!
===== added 04/17/2015
Here were the commands I tried:
$p=$(Get-WmiObject -class "MSNdis_CurrentPacketFilter" -NameSpace "root\WMI" -Filter "InstanceName='Intel(R) Ethernet Server Adapter I350-T2'").__Path
Write-Host $p
\\HYPERV88\root\WMI:MSNdis_CurrentPacketFilter.InstanceName="Intel(R) Ethernet Server Adapter I350-T2"
Set-WmiInstance -Path $p -Arguments #{NdisCurrentPacketFilter=47}
and error (not sure why it said command not found, but command was valid)
Set-WmiInstance : Not found
At line:1 char:1
+ Set-WmiInstance -Path $p -Arguments #{NdisCurrentPacketFilter=47}
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Set-WmiInstance], ManagementException
+ FullyQualifiedErrorId : SetWMIManagementException,Microsoft.PowerShell.Commands.SetWmiInstance
And I tried this:
$o = Get-WmiObject -class "MSNdis_CurrentPacketFilter" -NameSpace "root\WMI" -Filter "InstanceName='Intel(R) Ethernet Server Adapter I350-T2'"
Write-Host $o
\\HYPERV88\root\WMI:MSNdis_CurrentPacketFilter.InstanceName="Intel(R) Ethernet Server Adapter I350-T2"
Set-WMIInstance -class "MSNdis_CurrentPacketFilter" -InputObject $o -Arguments #{NdisCurrentPacketFilter=47}
Set-WmiInstance : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Set-WMIInstance -class "MSNdis_CurrentPacketFilter" -InputObject $o -Arguments # ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-WmiInstance], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.SetWmiInstance
I think you are having this issue as according to scriptinternals that value is read-only.
NdisCurrentPacketFilter
Data type: integer/usint32
Access type: Read-only
I found similar information here as well. You should have wrote your error here as well. It might have added context to your issue and it is a best practice when asking questions.
Disclaimer: I know nothing about the class. Just wanted to see if anyone posted details of the class parameters.