SAPIEN Technologies, Inc., PowerShell Studio 2017 v5.4.145
Windows 10 x64
Hello
Can you please help me with the following question as it is very frustrating and I find myself reverting back to using PowerGUI which does provide intelesense on as I would expect (however I do not want to keep reverting back to a free IDE when I have paid for PowerShell Studio), thanks
if I execute the following code in PowerGUI
clear-host
Add-Type -AssemblyName PresentationCore, PresentationFramework, WindowsBase
$String = @"
<Window Name="MainWindow" BorderBrush="AliceBlue" BorderThickness="15"
xmlns="http://schemas.microsoft.com/winfx/2006 ... esentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Code Signing Utility" Height="385" Width="565">
<Window.Effect>
<DropShadowEffect/>
</Window.Effect>
<Grid>
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="22,29,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="166" Width="476" FontFamily="Arial"><Run Text="This utility is designed to Sign Code (e.g. Java, PowerShell, etc.) using a trusted code signing certificate. The utility also offers the ability to time stamp the signature at time of signing."/><LineBreak/><Run/><LineBreak/><Run Text="In addition the utility also records all the the code signing actions taken to a central for auditing purposes"/><LineBreak/><Run/><LineBreak/><Run Text="Only authorized personnel will be able to run this utility"/><LineBreak/><Run/><LineBreak/><Run Text="For further information please refer to the author noted in the title bar of this window"/><LineBreak/><Run/><LineBreak/><Run/><LineBreak/><Run/></TextBlock>
<Button x:Name="button" Content="Next" HorizontalAlignment="Left" Margin="423,280,0,0" VerticalAlignment="Top" Width="75"/>
<Button x:Name="button1" Content="Exit" HorizontalAlignment="Left" Margin="22,280,0,0" VerticalAlignment="Top" Width="75"/>
</Grid>
</Window>
"@
[xml]$XAML = ($String -replace "x:")
$reader = New-Object System.Xml.XmlNodeReader $XAML
$Win = [System.Windows.Markup.XamlReader]::Load($reader)
then I type $Win. I would expect to see the methods available to the object $Win however I do not. If I do the same in PowerGUI I do see the methods for example ShowDialog and many more. In fact in PowerGUI I do not even have to execute the code to see the methods available.
This is very frustrating, can you please explain how to resolve this,
ErnieB
PowerShell Studio not showing methods
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION 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.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
DO NOT POST LICENSE NUMBERS, ACTIVATION 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.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: PowerShell Studio not showing methods
In order to retain the object state information, you must first hit a breakpoint in the debugger:
1. Set a breakpoint after you assign the $Win variable.
2. Run the Debugger (F5).
3. When the Debugger breaks at the specified breakpoint, it will take a snapshot of the variable states at that moment in time.
4. Exit Debugger and you should get PrimalSense for the $Win object.
https://www.sapien.com/blog/2017/07/20/ ... -v5-4-142/
1. Set a breakpoint after you assign the $Win variable.
2. Run the Debugger (F5).
3. When the Debugger breaks at the specified breakpoint, it will take a snapshot of the variable states at that moment in time.
4. Exit Debugger and you should get PrimalSense for the $Win object.
https://www.sapien.com/blog/2017/07/20/ ... -v5-4-142/
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: PowerShell Studio not showing methods
Another alternative is to cast the variable:
[System.Windows.Window]$Win = [System.Windows.Markup.XamlReader]::Load($reader)
This will ensures PowerShell Studio's PrimalSense uses the specified type.
[System.Windows.Window]$Win = [System.Windows.Markup.XamlReader]::Load($reader)
This will ensures PowerShell Studio's PrimalSense uses the specified type.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: PowerShell Studio not showing methods
Hello David
Thanks for the reply adding
[System.Windows.Window]$Win = [System.Windows.Markup.XamlReader]::Load($reader)
Fixed the issue with Intelesense with regards to available methods and properties.
I have another query possibly related issue, when I run the following code from PowerGUI or the command line it works as expected (not finished code) e.g. does not prompt me for any thing just runs
when I run via the PowerShell Studio is prompts me with Parameters: -AuthorisedGroupSID "S-1-5-21-3674026133-984544165-2712361304-999999" and I have to select OK to continue, any idea why it is prompting me please?
# Author Ernest Brant
# Version 1.0
[cmdletbinding()]
param ($AuthorisedGroupSID = "S-1-5-21-3674026133-984544165-2712361304-999999")
clear-host
Add-Type -AssemblyName PresentationCore, PresentationFramework, WindowsBase
#region functions
function Close-MainWindow
{
$Win.Close()
}
function Check-UserIsAuthorised
{
[cmdletbinding()]
param ($AuthorisedGroupSID)
$UsersGroups = @([System.Security.Principal.WindowsIdentity]::GetCurrent().Groups | Select-Object -ExpandProperty Value)
if ($UsersGroups -notcontains $AuthorisedGroupSID) { return "NotAuthorised" }
else { return "Authorised" }
}
#endregion functions
$String = @"
<Window Name="MainWindow" BorderBrush="AliceBlue" BorderThickness="15"
xmlns="http://schemas.microsoft.com/winfx/2006 ... esentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Code Signing Utility (Author: Ernest Brant Version: 1.0)" Height="385" Width="565">
<Window.Effect>
<DropShadowEffect/>
</Window.Effect>
<Grid>
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="22,29,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="166" Width="476" FontFamily="Arial"><Run Text="This utility is designed to Sign Code (e.g. Java, PowerShell, etc.) using a trusted code signing certificate. The utility also offers the ability to time stamp the signature at time of signing."/><LineBreak/><Run/><LineBreak/><Run Text="In addition the utility also records all the the code signing actions taken to a central for auditing purposes"/><LineBreak/><Run/><LineBreak/><Run Text="Only authorized personnel will be able to run this utility"/><LineBreak/><Run/><LineBreak/><Run Text="For further information please refer to the author noted in the title bar of this window"/><LineBreak/><Run/><LineBreak/><Run/><LineBreak/><Run/></TextBlock>
<Button x:Name="MainWindowsNextbutton" Content="Next" HorizontalAlignment="Left" Margin="423,280,0,0" VerticalAlignment="Top" Width="75" />
<Button x:Name="MainWindowClosebutton" Content="Exit" HorizontalAlignment="Left" Margin="22,280,0,0" VerticalAlignment="Top" Width="75" />
</Grid>
</Window>
"@
[xml]$XAML = ($String -replace "x:")
$reader = New-Object System.Xml.XmlNodeReader $XAML
#$Win = [System.Windows.Markup.XamlReader]::Load($reader)
[System.Windows.Window]$Win = [System.Windows.Markup.XamlReader]::Load($reader)
$MainWindowNextButton = $Win.FindName("MainWindowsNextbutton")
$MainWinowCloseButton = $Win.FindName("MainWindowClosebutton")
[Void]$MainWinowCloseButton.add_Click({ Close-MainWindow })
[Void]$MainWinowCloseButton.add_MouseEnter({ $MainWinowCloseButton.Cursor = "Hand" })
[Void]$MainWindowNextButton.add_MouseEnter({ $MainWindowNextButton.Cursor = "Hand" })
[Void]$MainWindowNextButton.add_Click({
$Result = Check-UserIsAuthorised -AuthorisedGroupSID $AuthorisedGroupSID
if ($Result -eq "NotAuthorised")
{
}
})
[Void]$Win.ShowDialog()
Thanks for the reply adding
[System.Windows.Window]$Win = [System.Windows.Markup.XamlReader]::Load($reader)
Fixed the issue with Intelesense with regards to available methods and properties.
I have another query possibly related issue, when I run the following code from PowerGUI or the command line it works as expected (not finished code) e.g. does not prompt me for any thing just runs
when I run via the PowerShell Studio is prompts me with Parameters: -AuthorisedGroupSID "S-1-5-21-3674026133-984544165-2712361304-999999" and I have to select OK to continue, any idea why it is prompting me please?
# Author Ernest Brant
# Version 1.0
[cmdletbinding()]
param ($AuthorisedGroupSID = "S-1-5-21-3674026133-984544165-2712361304-999999")
clear-host
Add-Type -AssemblyName PresentationCore, PresentationFramework, WindowsBase
#region functions
function Close-MainWindow
{
$Win.Close()
}
function Check-UserIsAuthorised
{
[cmdletbinding()]
param ($AuthorisedGroupSID)
$UsersGroups = @([System.Security.Principal.WindowsIdentity]::GetCurrent().Groups | Select-Object -ExpandProperty Value)
if ($UsersGroups -notcontains $AuthorisedGroupSID) { return "NotAuthorised" }
else { return "Authorised" }
}
#endregion functions
$String = @"
<Window Name="MainWindow" BorderBrush="AliceBlue" BorderThickness="15"
xmlns="http://schemas.microsoft.com/winfx/2006 ... esentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Code Signing Utility (Author: Ernest Brant Version: 1.0)" Height="385" Width="565">
<Window.Effect>
<DropShadowEffect/>
</Window.Effect>
<Grid>
<TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="22,29,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="166" Width="476" FontFamily="Arial"><Run Text="This utility is designed to Sign Code (e.g. Java, PowerShell, etc.) using a trusted code signing certificate. The utility also offers the ability to time stamp the signature at time of signing."/><LineBreak/><Run/><LineBreak/><Run Text="In addition the utility also records all the the code signing actions taken to a central for auditing purposes"/><LineBreak/><Run/><LineBreak/><Run Text="Only authorized personnel will be able to run this utility"/><LineBreak/><Run/><LineBreak/><Run Text="For further information please refer to the author noted in the title bar of this window"/><LineBreak/><Run/><LineBreak/><Run/><LineBreak/><Run/></TextBlock>
<Button x:Name="MainWindowsNextbutton" Content="Next" HorizontalAlignment="Left" Margin="423,280,0,0" VerticalAlignment="Top" Width="75" />
<Button x:Name="MainWindowClosebutton" Content="Exit" HorizontalAlignment="Left" Margin="22,280,0,0" VerticalAlignment="Top" Width="75" />
</Grid>
</Window>
"@
[xml]$XAML = ($String -replace "x:")
$reader = New-Object System.Xml.XmlNodeReader $XAML
#$Win = [System.Windows.Markup.XamlReader]::Load($reader)
[System.Windows.Window]$Win = [System.Windows.Markup.XamlReader]::Load($reader)
$MainWindowNextButton = $Win.FindName("MainWindowsNextbutton")
$MainWinowCloseButton = $Win.FindName("MainWindowClosebutton")
[Void]$MainWinowCloseButton.add_Click({ Close-MainWindow })
[Void]$MainWinowCloseButton.add_MouseEnter({ $MainWinowCloseButton.Cursor = "Hand" })
[Void]$MainWindowNextButton.add_MouseEnter({ $MainWindowNextButton.Cursor = "Hand" })
[Void]$MainWindowNextButton.add_Click({
$Result = Check-UserIsAuthorised -AuthorisedGroupSID $AuthorisedGroupSID
if ($Result -eq "NotAuthorised")
{
}
})
[Void]$Win.ShowDialog()
Re: PowerShell Studio not showing methods
When the editor detects a parameter block it will pop up a dialog so you can configure the parameters for testing and/or running the script. Without the dialog you would not be able to specify the parameters for the script.
Also "S-1-5-21-3674026133-984544165-2712361304-999999" is shown because that is the default value of the parameter.
Also "S-1-5-21-3674026133-984544165-2712361304-999999" is shown because that is the default value of the parameter.
David
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.