CMD not processing
 
Notifications
Clear all

We appreciate the contributions many of you have been able to make towards repairing the storm damage and keeping a roof over our heads. With your help we’ve been able to complete much of the critical work. There is still work to be done to secure the house and your continued support will be a huge help.

Guests have read-only access to our forums. If you wish to participate you will need to register. Be sure to activate your account from the email sent to you when you register.

CMD not processing

5 Posts
2 Users
0 Reactions
129 Views
Nathan_K
(@nathan_k)
Estimable Member Registered
Joined: 6 years ago
Posts: 144
Topic starter  

I'm running v3.22.0 (although this was tested in v3.21.0 also) and one of my PS1 custom scripts is not working correctly. If I copy the script out to an actual PS1 file and run it from Powershell it works correctly, but I'm getting no result (n/a) when trying to call it within the DesktopInfo app.

 

CMD=interval:60,color:55cc77,text:WiFi Status,onload,no-wait:2,read-as-csv:1, \
  csv-header:1,file:powershell.exe, parameters:-Command "& { %wifi-status% }", \
  trim:1,show-window:0,hide-no-result:0, alarms:(%BSSID% ne %BSSID% #ff0000), \
  display:SSID: %SSID%   Encryption: %Auth% / %Cipher%|   BaseStation ID: %BSSID%   Type: %NetType%|   Radio: %Radio%  {{{ Band: %Band%  }}} Channel: %Channel%   Signal: %Signal%

[wifi-status.ps1]
# Pull data from 'netsh' command and parse
$wifi_status = @( netsh wlan show interfaces )
$wifi_status = $wifi_status -replace '[\[\]=]',''
$wifi_status = $wifi_status.Replace(' : ',' = ')
$wifi_status = $wifi_status.Split('=').Trim()

If ( -not $wifi_status[ [Array]::indexOf($wifi_status,'State') + 1 ].Contains('connected') ) { Exit 0 }

For ( $i = 0; $i -lt $wifi_status.Count; $i++ ) {
    If ( [string]::IsNullOrEmpty($wifi_status[$i]) ) { $wifi_status[$i] = 'n/a' }
}

$State = $wifi_status[ [Array]::indexOf($wifi_status,'State') + 1 ]
$SSID = $wifi_status[ [Array]::indexOf($wifi_status,'SSID') + 1 ]

# Check for naming update from 'BSSID' to 'AP BSSID'
If ( [Array]::indexOf($wifi_status,'BSSID') -eq '-1' ) {
	$BSSID = $wifi_status[ [Array]::indexOf($wifi_status,'AP BSSID') + 1 ]
} Else {
	$BSSID = $wifi_status[ [Array]::indexOf($wifi_status,'BSSID') + 1 ]
}

# Check for AKM-24 cipher for Wifi 7 devices
$Cipher = $wifi_status[ [Array]::indexOf($wifi_status,'Cipher') + 1 ]
If ( $wifi_status[ [Array]::indexOf($wifi_status,'Connected Akm-cipher') + 2 ].Contains('00-0f-ac:24') ) {
	$Cipher = $Cipher + ' (AKM-24)'
}

$NetType = $wifi_status[ [Array]::indexOf($wifi_status,'Network type') + 1 ]
$Radio = $wifi_status[ [Array]::indexOf($wifi_status,'Radio type') + 1 ]
$Auth = $wifi_status[ [Array]::indexOf($wifi_status,'Authentication') + 1 ]
$Band = $wifi_status[ [Array]::indexOf($wifi_status,'Band') + 1 ]
$Channel = $wifi_status[ [Array]::indexOf($wifi_status,'Channel') + 1 ]
$Signal = $wifi_status[ [Array]::indexOf($wifi_status,'Signal') + 1 ]

# Output headers and data
Write-Host State ',' SSID ',' BSSID ',' NetType ',' Radio ',' Auth ',' Cipher ',' Band ',' Channel ',' Signal
Write-Host "$State" ',' "$SSID" ',' "$BSSID" ',' "$NetType" ',' "$Radio" ',' "$Auth" ',' "$Cipher" ',' "$Band" ',' "$Channel" ',' "$Signal"
Exit 0

   
Quote
Glenn
(@glenn)
Member Admin
Joined: 8 years ago
Posts: 1926
 

it works for me without any adjustments other than adding the SET-SECTION.  Better than my version  LOL!


   
ReplyQuote
Nathan_K
(@nathan_k)
Estimable Member Registered
Joined: 6 years ago
Posts: 144
Topic starter  

I do have the SET-SECTION in mine, I just forgot to add it to the code block in my original message. I'm wondering if MS changed something that's preventing DesktopInfo from properly processing it on my system. I know if I run the code directly it gives me the expected output.


   
ReplyQuote
Nathan_K
(@nathan_k)
Estimable Member Registered
Joined: 6 years ago
Posts: 144
Topic starter  

The super confusing part is that I have multiple other custom scripts being run, for BitLocker and Drive Status; WAN IP Address and Reverse DNS and CPU Microcode Revision, all of which are working just fine.


   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 8 years ago
Posts: 1926
 

Posted by: @nathan_k

I do have the SET-SECTION in mine, I just forgot to add it to the code block in my original message. I'm wondering if MS changed something that's preventing DesktopInfo from properly processing it on my system. I know if I run the code directly it gives me the expected output.

try putting %1 %2 %3 %4 on the CMD display output so you can see the exit/error codes at each stage. See page 80 -ish.

 


   
ReplyQuote
Glenn's Page