Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 22:20

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Powershell] mit ForEach String erzeugen

Discussion on [Powershell] mit ForEach String erzeugen within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
Mad0ck's Avatar
 
elite*gold: 313
Join Date: Oct 2014
Posts: 1,367
Received Thanks: 284
[Powershell] mit ForEach String erzeugen

Mahlzeit,

Bin aktuell auf ein Problem gestoßen, dass ich so nicht lösen kann.

Vorhaben:
Ich will ein Script schreiben, welches mir automatisch subscripte mit einem Template anlegt.

Problembeschreibung:
Ich habe ein array mit Scriptpfaden.
Ich will nun über das array loopen, und für jeden Eintrag den gleichen String erzeugen, um nicht 20x den gleichen code im script zu haben.

PHP Code:
# Beispiel Arrayeintrag
$scriptpaths=@("<serverURl>\<scriptName>.ps1")


$driverSetString=@"

# die 4 Zeilen sollen so oft wiederholt werden wie ich array Einträge habe
#region *** Executing ***
$script=$scriptpaths
powershell -file 
$script -Wait -Windowstyle Hidden
#endregion

"
@

$driverSetString out-file $outfile 
Ausgabe sollte dann wie folgt aussehen:
Beispiel: Array hat 4 Scriptpfade

Im Grunde ändert sich immer nur die $script Variable.

Ich könnte an sich string $driverSetString den part wo die Subscripte aufgerufen werden X-mal kopieren und die Scriptpfade dann via `$scriptpaths[0] - [-1] aufrufen.

Hätte es nur gerne simplifiziert, wenn man die 4 Zeilen irgendwie on the fly erstellen könnte.


Hoffe habe mein Anliegen so halbwegs verständlich beschreiben können.

LG
Mad0ck is offline  
Reply


Similar Threads Similar Threads
[Java] Objekte mit Foreach ausgeben
11/21/2014 - Java - 8 Replies
Hallo zusammen, Ich habe im Studium gerade mit Java angefangen und bräuchte mal ebend Hilfe. Ich habe eine Klasse Rohstoffe, eine Klasse Items und eine Klasse Main. In der Main-Klasse will ich über eine showShop()-Methode alle Rohstoffe in einer foreach-Schleife ausgeben lassen. Der Rohstoffe Konstruktor sieht wie folgt aus Rohstoffe(int id, String name, int strength, int cost, int price)
Finding a specific name from a list using a Foreach check
10/05/2013 - CO2 Private Server - 8 Replies
I've been working on a new event idea which involves 2 people being paired up and then parts of each char being checked against the other, I have everything working fine apart from 1 of the checks that selects the players opponent from the list by checking the names in the list, It only selects the first person added to the list and then returns a fail rather than checking the whole list and returning the correct match if they are still there, I have checked and players are being added fine and...
Mit Foreach mehrere Daten in MySQL eintragen^
07/12/2012 - Web Development - 4 Replies
Hallöchen community, komme gerade nicht weiter, steh irgendwie aufm Schlauch.. Ich habe folgendes: $xml = @simplexml_load_file($xmllink); foreach($xml->newsitems->newsitem as $news) { $title = $news->title; // Titel der News $url = $news->url; // Link zu den News
[VB08]String in String mit mehreren Funden
08/08/2011 - .NET Languages - 6 Replies
Hey, bin gerade auf ein Problem gestoßen, an dem ich mir seit 3 Stunden die Zähne ausbeiße. Ich will eine Funktion schreiben, die der _StringBetween Funktion von AutoIt gleich ist. _StringBetween gibt in einem Array alle Strings zwischen zwei SubStrings und dem ganzen String aus. Die Ausgabe bei _StringBetween("<h1>test1</h1>&l t;h1>test2</h1>", "<h1>", "</h1>") wäre also idealer Weiße ein Array (x = "test1", x = "test2")... da man in VB08 kein Array returnen kann, komme ich aber einfach...
Direct a foreach at Char in Map?
04/01/2010 - CO2 Private Server - 8 Replies
I've been working at a hunt quest that teleports chars to a map where they must kill a monster get a key find the treasure box, open it then teleport back to TC. This is what I have but it directs the tele to all characters in game foreach (Game.Character C in Game.World.H_Chars.Values) { Game.World.SendMsgToAll("SYSTEM", "The Treasure has been found. Better luck next time.", 2011, 0); ...



All times are GMT +1. The time now is 22:21.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.