Well i want only to know what i Have to do if that what read out (includs like words like "leiter" in Verkaufsabteilungsleiter or Gesamtleitung and save in Variables like MitgliedÄndern2, $Mitgliedlesen2 , $MitgliedÄndern3 , $Mitgliedlesen3 filtered out that this things doesn't generate.
Or It finds things like Verkaufsabteilung-Inland and add there something in String. So i think to compare two arrays are shorter If i write line for line.
if ($Abt -match "leiter") {$Standortsleitunglesen2 = $Mtl2 + "s" + "leitung" + "-" + "Lesen"}
if ($Abt -match "leiter") {$Standortsleitunglesen2 = $Mtl2 + "s" + "leitung" + "-" + "Lesen"}
if ($Standortsleitunglesen2 -match "Geschäft" ) {$Standortsleitunglesen2 = "" }
So i can set the terms in array2 and i don't need to write lots of lines and type it manualy. I hope you understand it now.
So I think my Solution goes in following direction:
$array = @($MitgliedÄndern2, $Mitgliedlesen2 , $MitgliedÄndern3 , $Mitgliedlesen3)
$array2 = "leiter" , "leitung"
for([int] $i = 0; $i -le ($array.Count -1); $i++)
{
foreach($word in $array2)
{
if($array[$i] -like "*$word*")
{
if ($array[$i] -match $MitgliedÄndern2) { ($MitgliedÄndern2 = "") }
if ($array[$i] -match $Mitgliedlesen2) { ($Mitgliedlesen2 = "") }
if ($array[$i] -match $MitgliedÄndern3) { ($MitgliedÄndern3 = "") }
if ($array[$i] -match $Mitgliedlesen3) { $Mitgliedlesen3 = ""}
$array[$i] = ""
}
}
}
I have a problem in Variables would generate Usernames of a Table of CSV. CSV: Inhalt
Nummer;Ordner1;Ordner2;Ordner3;Benutzername;;;Beschreibung;Mitglied;Mitglied 2;Gruppenbeschreibung;Gruppenbeschreibung 2
1;Hamburg;Geschäftsleitung;HH-GL;Stefan Berti;;;Standortleiter;GG-H-Geschäftsleiter;;Geschäftsleitung Hamburg;
in array2 i would like to Words that the the loop have to search in array1.
and if he find the string of array2 for example 'leiter' or another word like "Sekretär" in $array1 in $MitgliedÄndern2, $Mitgliedlesen2 , $MitgliedÄndern3 it would be Write "" in $MitgliedÄndern2, $Mitgliedlesen2 , $MitgliedÄndern3.
I have a method that works with an easy array but that method doesn't work in that example.
I'm new in Powershell and have find lots of things out but that. I don't know.
$File=Import-Csv '.\Datenbank\Hamburg.csv' -Delimiter ";" -Encoding UTF8 | foreach-object {
$Mtl1 = ""
$Mtl2 = ""
$Mtl3 = ""
$Org1 = ""
$Org2 = ""
$Org3 = ""
$Nummer = $_.Nummer
$User = ""
$Ordner1 = $_.Ordner1
$Ordner2 = $_.Ordner2
$Ordner3 = $_.Ordner3
$Beschreibung = $_.Gruppenbeschreibung
$Beschreibung2 = $_.Gruppenbeschreibung2
if ($Ordner1 -ne '') {$Org1 = echo HH}
if ($Ordner2 -ne '') {$Org2 = $($_.'Ordner2')}
if ($Ordner3 -ne '') {$Org3 = $($_.'Ordner3')}
$Mtl1 = "$Org1"
$Mtl2 = "$Org1" + "-" + "$Org2"
$Mtl3 = "$Org1" + "-" + "$Org2" + "-" + "$Org3"
#Lesen
$Mitgliedlesen3 = ""
$Mitgliedlesen2 = ""
$MitgliedÄndern3 = ""
$MitgliedÄndern2 = ""
$Bes = $_.Beschreibung
if ($Org3 -ne '') {$Mitgliedlesen3 = $Mtl3 + "-"+ "Lesen"}
if ($Org2 -ne '') {$Mitgliedlesen2 = $Mtl2 + "-" + "Lesen"}
$MitgliedÄndern2 = "Abteilungsleiter"
$Mitgliedlesen2 = "Bundesleiter"
$MitgliedÄndern3 = "Mitarbeiter"
$Mitgliedlesen3 = "Mitarbeiterleiter"
$array = $MitgliedÄndern2, $Mitgliedlesen2 , $MitgliedÄndern3
$array2 = "leiter" , ""
have tested follow things.
#$array3 = (Compare-Object $array2 $array).InputObject
#$Array4 = $Array | where {$_ -match "leiter"}
$result = $array | Where {$array -notContains "leiter"}
#$result = $array1 | ?{$_.Split('=')[0] -in ($array2 | %{$_.Split('=')[0]})}
#$result = compare $Array $Array2 -Property Key -IncludeEqual -ExcludeDifferent -,
Passthru $result
#$Array -like "*$array2*"
#$Array4
#$array3[0..1]
#ForEach ($array in $array2){
#$array -replace "^[$i0 .. $i]$array2",""
#}
.. }
thanks for help.