Search found 14133 matches

by jvierra
Fri Feb 21, 2020 1:30 pm
Forum: PowerShell GUIs
Topic: Message box with powershell studio - passing variables
Replies: 2
Views: 68

Re: Message box with powershell studio - passing variables

This is the correct way to do this:

Code: Select all

$msg = "Are you sure you want to kill process $process on computer $computername"
if('Yes' -eq [System.Windows.Forms.MessageBox]::Show($msg,'Warning','YesNo')){
#Do Stuff
}
Start by reading the following:

help about_quoting
by jvierra
Thu Feb 20, 2020 6:31 am
Forum: PowerShell GUIs
Topic: Buildversion, use exeversion to show in GUI?
Replies: 1
Views: 63

Re: Buildversion, use exeversion to show in GUI?

I recommend posting issues of how to use PSS to the Customer Support forum for PSS. Sapien techs will answer your questions about the product itself. The Community Forums are for PowerShell specific questions/
by jvierra
Thu Feb 20, 2020 6:29 am
Forum: PowerShell GUIs
Topic: ConvertDataset for GridView 'Invalid storage type: DBNull.'
Replies: 7
Views: 98

Re: ConvertDataset for GridView 'Invalid storage type: DBNull.'

You need to return a DataTable an not a dataset. Please review my code example wh9ioch shows how to do that.

I never use the function to load a sql table as it is unnecessary and can cause issues.
by jvierra
Wed Feb 19, 2020 1:10 pm
Forum: Windows PowerShell
Topic: Setting a variable once in a recursing function
Replies: 1
Views: 130

Re: Setting a variable once in a recursing function

Start by reading about "Advanced Functions" to learn how functions work and what can be done with them. help about_Functions_Advanced get-help about_functions*|fl name,synopsis The answer to your issue is to set the variable in teh "Begin" block of the function and use the function in a pipeline. YO...
by jvierra
Wed Feb 19, 2020 10:12 am
Forum: PowerShell GUIs
Topic: If statement resolves as true but doesn't run
Replies: 3
Views: 61

Re: If statement resolves as true but doesn't run

To test a field for null we would do the following: $dt.ROws[0]['autoval'].Value -eq [system.dbnull].Value Or this is easier: if($dt.Rows[0]['autoval'].Value){ This will automatically detect nulls in data fields. To check multiple fields: if($dt.Rows[0]['field1'].Value -and $dt.Rows[0]['field2'].Val...
by jvierra
Wed Feb 19, 2020 10:01 am
Forum: PowerShell GUIs
Topic: If statement resolves as true but doesn't run
Replies: 3
Views: 61

Re: If statement resolves as true but doesn't run

SQLFields do not resolve to null or empty. They either are checked with "DBNull" or by testing the "Value" member of the field. My best guess uis that you have assigned a field to the variable. This doesn't assign the contents it makes the variable a pointer to the field object. [System.DBNull]::Val...
by jvierra
Wed Feb 19, 2020 3:43 am
Forum: PowerShell GUIs
Topic: ConvertDataset for GridView 'Invalid storage type: DBNull.'
Replies: 7
Views: 98

Re: ConvertDataset for GridView 'Invalid storage type: DBNull.'

When you use a DataTable with a grid the column sort automatically. There is no need to add any code. It is just how the grid works. Adding code will just screw this up. Most of it depends on what you are sorting and how you loaded it. Without that information there is really no way for us to tell w...
by jvierra
Wed Feb 19, 2020 2:35 am
Forum: PowerShell GUIs
Topic: ConvertDataset for GridView 'Invalid storage type: DBNull.'
Replies: 7
Views: 98

Re: ConvertDataset for GridView 'Invalid storage type: DBNull.'

You cannot convert a dataset to a DataTable using that function. A dataset is already a DataTable. Why would you want to convert it?
by jvierra
Tue Feb 18, 2020 3:10 am
Forum: Windows PowerShell
Topic: Calling Powershell Function inside the Add-Member -InputObject ForEach loop?
Replies: 3
Views: 175

Re: Calling Powershell Function inside the Add-Member -InputObject ForEach loop?

That is not the intended use. The dates need no change. Changing them that way doesn't do anything useful that I can see. It just makes teh code more complicated and that has lead to many errors fo design and many, many needless lines of code. I also cannot quite understand what you are trying to as...
by jvierra
Tue Feb 18, 2020 1:27 am
Forum: Windows PowerShell
Topic: Calling Powershell Function inside the Add-Member -InputObject ForEach loop?
Replies: 3
Views: 175

Re: Calling Powershell Function inside the Add-Member -InputObject ForEach loop?

You can just add a computed property that calls the function. Add-Member is a very inefficient way to build an object. If you use a [pscustomobject] then it would be much esier to write your code and then just retrieve the function data and add it to the object. [pscustomobject]@{ Prop1 = $value1 Pr...