NET Calls not working on PS Studio

Use this forum to ask questions after your subscription maintenance expires or before you buy. Need information on licensing or pricing? Questions about a trial version? This is the right place for you. No scripting questions, please.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.
This topic is 1 year and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
mar10c--
Posts: 59
Last visit: Mon May 22, 2023 6:53 am

NET Calls not working on PS Studio

Post by mar10c-- »

Product, version and build: PS Studio 2022 Trial Version and PS Studio 2019
Operating system: Win 11
PowerShell version(s): 5.x.x
32-bit version of software? 64

Code below runs on Windows Powershell IDE but not on PS Studio 2022 or PS Studio 2019. $res is stucked "Loading value".
$comp = <'ip'>
$res = New-Object System.Net.NetworkInformation.Ping
$res.Send("$comp", 10000)
Untitled.png
Untitled.png (15.38 KiB) Viewed 2762 times
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: NET Calls not working on PS Studio

Post by Alexander Riedel »

A bit of a generalization in the title there. This is an asynchronous call. You need to turn on STA mode if you use those.
>> Running (pinger.ps1) Script...
>> Platform: V7 64Bit (STA)
>> Analyzing Script (Results in Tools Output panel)...

Status        : Success
Address       : 192.168.1.254
RoundtripTime : 4
Options       : System.Net.NetworkInformation.PingOptions
Buffer        : {97, 98, 99, 100…}



*** PowerShell Script finished. ***
>> Execution time: < 1 second
>> Script Ended
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
mar10c--
Posts: 59
Last visit: Mon May 22, 2023 6:53 am

Re: NET Calls not working on PS Studio

Post by mar10c-- »

In my test V7 works whether STA or not. It does not work on V5 STA or not.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: NET Calls not working on PS Studio

Post by Alexander Riedel »

Seems to operate fine here:
>> Running (pinger.ps1) Script...
>> Platform: V5 64Bit (STA)
>> Analyzing Script (Results in Tools Output panel)...

Name                           Value
----                           -----
PSVersion                      5.1.19041.2364
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.2364
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Status        : Success
Address       : 192.168.1.254
RoundtripTime : 1
Options       : System.Net.NetworkInformation.PingOptions
Buffer        : {97, 98, 99, 100...}




*** PowerShell Script finished. ***
>> Execution time: < 1 second
>> Script Ended
This is on Windows 10. Don't have a Win 11 machine here at the moment. I doubt it matters, but you never know.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
mar10c--
Posts: 59
Last visit: Mon May 22, 2023 6:53 am

Re: NET Calls not working on PS Studio

Post by mar10c-- »

It is strange how this works on Win 11 Windows Powershell IDE 5.x. What PS Studio version are you testing on?
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: NET Calls not working on PS Studio

Post by Alexander Riedel »

5.8.213, the latest one released. I have also tested this in PrimalScript on Windows 11 by now and it has the same result.
There is something else at play I am afraid.
Please note that the ISE, PowerShell Studio, PrimalScript all use the same PowerShell. We are not having a private version.
There can be hosting differences when it comes to output, sure, but for that type of thing there should not be any difference from our end.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: NET Calls not working on PS Studio

Post by Alexander Riedel »

Are you pinging an address outside your firewall?
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
mar10c--
Posts: 59
Last visit: Mon May 22, 2023 6:53 am

Re: NET Calls not working on PS Studio

Post by mar10c-- »

This is an isolated network no firewalls in between. Can you try SendPingAsync
(New-Object Net.NetworkInformation.Ping).SendPingAsync($IPAddr, 10000)
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: NET Calls not working on PS Studio

Post by Alexander Riedel »

Works like a charm
>> Running (pinger.ps1) Script...
>> Platform: V5 64Bit (STA)
>> Analyzing Script (Results in Tools Output panel)...

Name                           Value
----                           -----
PSVersion                      5.1.19041.2364
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.2364
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Result                 : System.Net.NetworkInformation.PingReply
Id                     : 16
Exception              :
Status                 : RanToCompletion
IsCanceled             : False
IsCompleted            : True
CreationOptions        : None
AsyncState             :
IsFaulted              : False
AsyncWaitHandle        : System.Threading.ManualResetEvent
CompletedSynchronously : False




*** PowerShell Script finished. ***
>> Execution time: 00:00:01
>> Script Ended
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
mar10c--
Posts: 59
Last visit: Mon May 22, 2023 6:53 am

Re: NET Calls not working on PS Studio

Post by mar10c-- »

I am thinking about upgrading to Studio 5.8.213 but it had issues with SSH cmd prompt showing. Someone is looking into it but would be nice if that could be expedited here is the link to the post : viewtopic.php?t=16135
This topic is 1 year and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.