After
I am writing some code to figure out how to list volumes of values in more manageable pieces. The reason for this is that I have received around 100,000 live value and I want to reduce the risk of failure.
$ wholeList = $ 1..100 $ nextStartingPoint $ workList function Get- NextTenItems () {$ workingList = (1 + $ nextStartingPoint) .. (10 + $ nextStartingPoint) $ nextStartingPoint + = 10 Write host - write host-host "nights-nextTenItems inside" "next StartingPoint: $ nextStartingPoint" $ workingList Write host "go out- NextTenItems"} Function Write-ListItems () {foreach ($ li $ in the working list) {Write - Host $ li}} Go-Agentain Write List-List Item Received-NextThen-List Write-List I ran the code in the Power GUI debugger and I got my $ next startpoint I have watched, when I exit the Get-NextTenItems function.
Why is this happening and how can I stop it?
Should I also believe that the same thing $ $ is working?
In your example get-uplistime in its local Variable changes There are several ways to solve this problem, two of them are here: 1) Specifically specify variable scope (prefix script or Global ). That is, use those variables in the form of the $ script: next startpoint , $ script: agenda inside the function. 2) Change the scope of its function. That is, call the function using the dot operator ("dot-source" function), that is, execute it in the current radius. This code works as expected (no other necessary changes):
Go-NextTance History list-list requirements Get-NextTenItems Type-ListItems Also
help about_scopes
Comments
Post a Comment