File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change 9
9
using System . Globalization ;
10
10
using System . Linq ;
11
11
using System . Management . Automation ;
12
+ using System . Management . Automation . Host ;
12
13
using System . Management . Automation . Language ;
13
14
using System . Management . Automation . Runspaces ;
14
15
using System . Reflection ;
@@ -625,13 +626,9 @@ private PSConsoleReadLine()
625
626
{
626
627
try
627
628
{
628
- ps . AddCommand ( "Get-Variable" ) . AddParameter ( "Name" , "host" ) . AddParameter ( "ValueOnly" ) ;
629
- var results = ps . Invoke ( ) ;
630
- dynamic host = results . Count == 1 ? results [ 0 ] : null ;
631
- if ( host != null )
632
- {
633
- hostName = host . Name as string ;
634
- }
629
+ var results = ps . AddScript ( "$Host" ) . Invoke < PSHost > ( ) ;
630
+ PSHost host = results . Count == 1 ? results [ 0 ] : null ;
631
+ hostName = host ? . Name ;
635
632
}
636
633
catch
637
634
{
You can’t perform that action at this time.
0 commit comments