Log Quesiton

  • 8 April 2022
  • 1 reply

Userlevel 1

Is there a way to echo a command and make the status of a worklet visible?


Example; if I sent a PS command to a system lets say to unjust something. I would like to see something in the logs showing a status. 

Get-NetAdapter | foreach { Disable-NetAdapterBinding -InterfaceAlias $_.Name -ComponentID ms_tcpip6 }

Current log shows: 


nothing else.

Maybe something on how to echo the results or response from the command.


Best answer by jack.smith 12 April 2022, 02:28

View original

1 reply

Userlevel 5
Badge +1

@daniel.newman one way to get more output is to introduce some Boolean logic and add in the logging of choice based on what is being done. 

Get-NetAdapter | ForEach-Object {

# Get Current State
$ip6 = Get-NetAdapterBinding -InterfaceAlias $_.Name -ComponentID ms_tcpip6

# React to Current State
IF($ip6.Enabled -eq $true){

# Disable
Disable-NetAdapterBinding -InterfaceAlias $_.Name -ComponentID ms_tcpip6

# Check Status of Disabling
Write-Output "Net Adapter [ $($_.Name) ] ms_tcpip6 was successfully disabled. "
Write-Output "Net Adapter [ $($_.Name) ] ms_tcpip6 was not disabled. "

# Disabled
Write-Output "Net Adapter [ $($_.Name) ] ms_tcpip6 already disabled. "

} # end ForEach

Using $? in powershell is pretty cool. I’d check out Automatic Variables here --