I have a one-dimensional array that I get from the matching content command or multi-line text box input. I want to assign an asset to entries in this array, then add more properties to use later in my script.
Something like this:
$ items = new-object Psobject $ item | Add-member -membertip noteproperty -name name-value notset $ items | Add-member-memberType noteproperty -name percentage-value NotSet $ names = @ ($ textboxInputText.Lines) $ name | % {$ Item | $ $ Name = $ script ($ $ name)} foreach ($ item $ item) {$ percent = {script block} $ item.percent = $ percent}
I know That's a broken code, but I wanted to give an example of where I was going. I have searched very far, but in fact I can not find what I am looking for.
Edit:
Code target: Get input From a text box or text file (single row entries), those entries in the "Name" property Assign, then add another asset in the array (percent), which will need to be filled in the second block of code. Edit
$ Item) {$ psConsoleFile = "PATH to FILE.pc1" $ variable1 = "Something" $ variable2 = "Something else" $ command = "." "Command1 $ item.name | | Command2 -Switch $ variable1 -Switch2 $ variable2`" "$ Output ScriptBlock =" PowerShell.exe -PinesSolphile $ psConsoleFile -command $ command "} < P> Its output is as follows: powershell.exe -PSConsoleFile "PATH to FILE.psc1" - Command. "Command1 @ {name = name1; Percent =}. Name | Command2-switches1 Something "
Why is the code to output the full line instead of the name
In addition to this, I have used PS 4.0 for all the implementations of this script
OK, I see a problem here, so you have a string of strings Array that you got from a text document with a multi-line text box form object or gate-content command, but the real What you want in the PSObjects is an array of.
In a string object, you can add extra properties like you want (well, not traditionally, let's just not go there. Because you will not be happy, where things will end, trust me.) Instead, we take that array of stars, and create a PSObject for each string as you want. ForEach-ob Either you want to simplify the loop. Either way, you want to pip your input (either text box or content command) into a pie loop, and you can specify the whole thing in a variable which will later (The percent property will collect all the objects to work with the object) Something like this is what you want to do:
[array] $ collection = $ textboxInputText.Lines | For <{code> $ store
type is specified as
I { $ archive
so that if you want to index it later, then any issue Should not be, your input should be only one item, and if you want to update the percentages that you can do that can be a forEach loop (either inline or No) by running $ archive
$ archive | $ {$ Item in the $ archive} {$ Item.Percentage = $ {$} for $ {script} {$ code = $ {script block}}
or
blocks}}
Now, things to note here ... You will not be able to return just $ text to your textbox. You can probably invite the $ archive. The name, but it may require a new version of PS because I do not know how it is backwards compatible. If you use the gate-content command instead of referencing the text box, just replace Edit: OK, you no longer have the problem with the object, but how are you trying to expand its assets within a double quotes using the name You must wrap the $ textboxInputText.Lines. Unit {
to
go-content "c: \ path \ to \ file.txt" |
$ Item.Name
inside $ ()
to create sub-expression within double quotation marks. That's why you'll see that line:
$ command = "." Command1 $ ($ item.name) | Command2 - Switch $ variable1 -Switch2 $ variable2` ""
No comments:
Post a Comment