get-childitem combobox

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 4 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.
Locked
User avatar
mxtrinidad
Posts: 399
Last visit: Tue May 16, 2023 6:52 am

Re: get-childitem combobox

Post by mxtrinidad »

If your goal is to use Get-ChildItem for the server you selected, it would help to provide the correct string format.

For example, instead of using;
Get-ChildItem $comboboxServers.selecteditem

Try the following example:
$serverpath = '\\'+"$($comboboxServers.selecteditem)"+'\c$';
Get-ChildItem $serverpath

See it this will give you the expected result.
User avatar
apowershelluser
Posts: 194
Last visit: Mon Apr 15, 2024 3:21 pm
Answers: 2

Re: get-childitem combobox

Post by apowershelluser »

mxtrinidad wrote: Fri Dec 01, 2017 8:36 am If your goal is to use Get-ChildItem for the server you selected, it would help to provide the correct string format.

For example, instead of using;
Get-ChildItem $comboboxServers.selecteditem

Try the following example:
$serverpath = '\\'+"$($comboboxServers.selecteditem)"+'\c$';
Get-ChildItem $serverpath

See it this will give you the expected result.
It's working as I imaged
I don't need to do a $serverpath because comoboxbox is populated with the full path
\\server\data\user
\\server\data\user2
etc...
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: get-childitem combobox

Post by davidc »

For an example on how to use the Job-Tracker, use the Button - Start Job control set or refer to the following article:

https://info.sapien.com/index.php/guis/ ... sive-forms
David
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: get-childitem combobox

Post by jvierra »

Start-JobTracker Takes a parameter "-ArgumentList" which is passed to the JobTracker script block as an argument. Use this to pass the value as the default argument in you script block,

From the code you posted:

Code: Select all

Add-JobTracker -ArgumentList $comboboxServers.selecteditem -Name 'JobNameQueryServer' `
               -JobScript {
    #--------------------------------------------------
    #TODO: Set a script block
    #Important: Do not access form controls from this script block.
    
    Param ($Argument1) #Pass any arguments using the ArgumentList parameter
    
    #	---------------------------------
    #	Sample Code to Load Sortable Data
    #	---------------------------------
    
    Get-ChildItem $Argument1
    
    #--------------------------------------------------
}`
This is what I meant by reading the help comments. You had them and posted them but were not reading them.
User avatar
apowershelluser
Posts: 194
Last visit: Mon Apr 15, 2024 3:21 pm
Answers: 2

Re: get-childitem combobox

Post by apowershelluser »

davidc wrote: Fri Dec 01, 2017 9:30 am For an example on how to use the Job-Tracker, use the Button - Start Job control set or refer to the following article:

https://info.sapien.com/index.php/guis/ ... sive-forms
I started with that control set and worked my way up. The problem as stated in my next post is there's not true example. Is it lack of my understanding? I can understand that, but to not make an update to that blog, that explicitly deals with arguments creates most of these threads.

All of you are top notch. Just remember, some of us are just starting and only need a few examples to wrap our heads around it.
Last edited by apowershelluser on Fri Dec 01, 2017 10:28 am, edited 1 time in total.
User avatar
apowershelluser
Posts: 194
Last visit: Mon Apr 15, 2024 3:21 pm
Answers: 2

Re: get-childitem combobox

Post by apowershelluser »

jvierra wrote: Fri Dec 01, 2017 10:00 am Start-JobTracker Takes a parameter "-ArgumentList" which is passed to the JobTracker script block as an argument. Use this to pass the value as the default argument in you script block,

From the code you posted:

Code: Select all

Add-JobTracker -ArgumentList $comboboxServers.selecteditem -Name 'JobNameQueryServer' `
               -JobScript {
    #--------------------------------------------------
    #TODO: Set a script block
    #Important: Do not access form controls from this script block.
    
    Param ($Argument1) #Pass any arguments using the ArgumentList parameter
    
    #	---------------------------------
    #	Sample Code to Load Sortable Data
    #	---------------------------------
    
    Get-ChildItem $Argument1
    
    #--------------------------------------------------
}`
This is what I meant by reading the help comments. You had them and posted them but were not reading them.
That sentence is laughable. Do me a favor, show me in the help or the blog post where it gives an example.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: get-childitem combobox

Post by jvierra »

The link David posted is a clear example and the text I just posted explains and shows an exact example.

I will highlight it for you:

Add-JobTracker -ArgumentList $comboboxServers.selecteditem -Name 'JobNameQueryServer'

and

Get-ChildItem $Argument1
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: get-childitem combobox

Post by jvierra »

JohnTitor wrote: Fri Dec 01, 2017 10:25 am
That sentence is laughable. Do me a favor, show me in the help or the blog post where it gives an example.

If you read the blog post carefully you will see an explicit example. The "Function Add-JobTracker" has the arguments and the example right at the top starting with:
.PARAMETER ArgumentList
The arguments to pass to the job
And:
#Start the Job
$job = Start-Job -Name $Name -ScriptBlock $JobScript -ArgumentList $ArgumentList
And:
$buttonStartJob_Click={

$buttonStartJob.Enabled = $false

#Create a New Job using the Job Tracker
Add-JobTracker -Name "JobName" `
-JobScript {
#--------------------------------------------------
#TODO: Set a script block
#Important: Do not access form controls from this script block.

Param($Argument1)#Pass any arguments using the ArgumentList parameter
User avatar
apowershelluser
Posts: 194
Last visit: Mon Apr 15, 2024 3:21 pm
Answers: 2

Re: get-childitem combobox

Post by apowershelluser »

You mean in this link, https://info.sapien.com/index.php/guis/ ... sive-forms

There is an real example of using arguments?

Hmm, I see 4 examples of -argument and 18 uses of the word argument

Guess I need to go back to elementary
User avatar
apowershelluser
Posts: 194
Last visit: Mon Apr 15, 2024 3:21 pm
Answers: 2

Re: get-childitem combobox

Post by apowershelluser »

jvierra wrote: Fri Dec 01, 2017 11:05 am
JohnTitor wrote: Fri Dec 01, 2017 10:25 am
That sentence is laughable. Do me a favor, show me in the help or the blog post where it gives an example.

If you read the blog post carefully you will see an explicit example. The "Function Add-JobTracker" has the arguments and the example right at the top starting with:
.PARAMETER ArgumentList
The arguments to pass to the job
And:
#Start the Job
$job = Start-Job -Name $Name -ScriptBlock $JobScript -ArgumentList $ArgumentList
And:
$buttonStartJob_Click={

$buttonStartJob.Enabled = $false

#Create a New Job using the Job Tracker
Add-JobTracker -Name "JobName" `
-JobScript {
#--------------------------------------------------
#TODO: Set a script block
#Important: Do not access form controls from this script block.

Param($Argument1)#Pass any arguments using the ArgumentList parameter
Yes, I saw all of these, none of the provide the example for the argument - so you're skipping the most important part

I guess as the posts starts " This article will not cover the ins and outs of jobs and it expects the user has some basic knowledge of the jobs mechanism in PowerShell. "
This topic is 6 years and 4 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.
Locked