PowerShell: "Es wurde kein Positionsparameter gefunden, der das Argument "+" akzeptiert." Wie löse ich das?

Hi

Es geht um Reports... Programmiert wurde es mit PowerShell ISE

Hier der Fehler:

Rename-Item : Es wurde kein Positionsparameter gefunden, der das    Argument  "+" akzeptiert.
In Zeile:34 Zeichen:1
+ rename-item "c:\Reporting\Report_Telephone_" + $todaydate[0] +'-' + $todaydate[1 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Rename-Item], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.RenameItemCommand

hier mein Code:

#today's date (year-month-day)
$todaydate = Get-Date -Format yyyy-MM-dd

#arrays  (today => systemtime)
$todaydate = $todaydate.Split('-')
$todaydate[0] #year
$todaydate[1] #month
$todaydate[2] #day

#arrays yesterday (systemtime - one day)
$yesterdaysdate = Get-Date((Get-Date).AddDays(-1)) -Format yyyy-MM-dd
$yesterdaysdate = $yesterdaysdate.Split('-')
$yesterdaysdate[0] #year
$yesterdaysdate[1] #month
$yesterdaysdate[2] #day

#arrays yesterday (systemtime - one day)
$lastmonth = Get-Date((Get-Date).AddMonths(-1)) -Format yyyy-MM-dd
$lastmonth = $lastmonth.Split('-')
$lastmonth[0] #year
$lastmonth[1] #month
$lastmonth[2] #day


#Example 1:  Filename "Report_Telephone_yyyy-mm" => in this case "Report_Telephone_2016-12"
#it renames the file -> minus one month, so the name must be "Report_Telephone_2016-11"
$filename='Report_Telephone_'+ $lastmonth[0]+'-'+ $lastmonth[1] + '.xlsx'
$filemonth = [int][regex]::Match($filename, '\w+_\d+_(\d+)').Groups[1].Value
$filemonth = "{0:D2}" -f ($filemonth - 1)

write-host $filename
rename-item "c:\Reporting\Report_Telephone_" + $todaydate[0] +'-' + $todaydate[1] + ".xlsx" -NewName $filename

$sourcepath='C:\Reporting\'+ $filename
write-host $sourcepath
$destinationpath='C:\Reporting\'+ $lastmonth[0]+'\'+ $lastmonth[1]
write-host $destinationpath
if(test-path $destinationpath)
{

} 
else 
  {
     mkdir $destinationpath
  }
move-item -path $sourcepath -destination $destinationpath

Hat einer ne Idee, wie ich das lösen könnte? Thx im vorraus :3

PC, Computer, Windows, IT, programmieren, Informatik, PS, Report, Script, PowerShell, Powershell ISE
Mit der Eingabeaufforderung ein Powershellscript ausführen?

Hallo, ich mochte ein (simples) Powershell-Script mit der Eingabeaufforderung starten.

Das Batch-Script sieht bisher so aus:

@echo off
del %tmp%\drive.ps1
echo Set-ExecutionPolicy RemoteSigned >%tmp%\drive.ps1
echo New-PSDrive -Name S -PSProvider FileSystem -Root \\MYCLOUDEX2ULTRA\Public -Persist >>%tmp%\drive.ps1
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile & "%tmp%\drive.ps1"

Die Datei startet zwar die PowerShell aber nicht die Datei. (Und fragt danach wie ich sie öffnen möchte)

Wenn ich es allerdings do angehe:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile "%tmp%\drive.ps1"

bekomme ich diesen lustigen Fehler:

C:\Users\nikla\AppData\Local\Temp\drive.ps1 : Die Datei "C:\Users\nikla\AppData\Local\Temp\drive.ps1" kann nicht
geladen werden, da die Ausführung von Skripts auf diesem System deaktiviert ist. Weitere Informationen finden Sie
unter "about_Execution_Policies" (https:/go.microsoft.com/fwlink/?LinkID=135170).
In Zeile:1 Zeichen:1
+ C:\Users\nikla\AppData\Local\Temp\drive.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : Sicherheitsfehler: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

Und ohne -NoProfile kommt exakt der gleiche Fehler.

Soah, nun bin ich mit mein Latein am Ende. Könnt ihr mir da weiterhelfen?

Windows, cmd, Eingabeaufforderung, PowerShell
Wieso funktionier bei mir [System.Windows.MessageBox]::Show($DropDown)::OK in PowerShell nicht??

Hallo,
wo liegt die Fehler wieso funktioniert der [System.Windows.MessageBox]::Show($DropDown)::OK Befehl in meiner Code nicht??

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

  [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")

  

  $Form = [System.Windows.Forms.MessageBox]::OK

   

  $Form.width = 300

  $Form.height = 150

  $Form.Text = ”DropDown”

  

  $DropDown = [System.Windows.MessageBox]::Show($DropDown)::OK

  $DropDown.Location = new-object System.Drawing.Size(100,10)

  $DropDown.Size = new-object System.Drawing.Size(130,30)

  ForEach ($Item in $DropDownArray) {

   [void] $DropDown.Items.Add($Item)

  }

  $Form.Controls.Add($DropDown)

  $DropDownLabel = [System.Windows.MessageBox]::Show($DropDown)::OK

  $DropDownLabel.Location = new-object System.Drawing.Size(10,10) 

  $DropDownLabel.size = new-object System.Drawing.Size(100,40) 

  $DropDownLabel.Text = "Suchen Sie die Pfad aus"

  $Form.Controls.Add($DropDownLabel)

    $Form.Controls.Add($DropDown)

  $DropDownLabel = [System.Windows.MessageBox]::Show($Form)::OK

  $DropDownLabel.Location = new-object System.Drawing.Size(10,10) 

  $DropDownLabel.size = new-object System.Drawing.Size(100,40) 

  $DropDownLabel.Text = "Zeit"

  $Form.Controls.Add($DropDownLabel)

  $Button = [System.Windows.MessageBox]::Show($Button)::OK

  $Button.Location = new-object System.Drawing.Size(100,50)

  $Button.Size = new-object System.Drawing.Size(100,20)

  $Button.Text = "Weiter"

  $Button.Add_Click({Return-DropDown})

  $form.Controls.Add($Button)

$result=[System.Windows.MessageBox]::Show($Form,$Button,$DropDownLabel,$DropDown,[System.Windows.MessageBoxResult]::OK)

   

  return $script:choice

Code, PowerShell
powershell script für vergleicher zweier Excel-dateien?

Hi Leutz,

ich brauche hilfe bei einem Powershell-Script das mir 2 riesige(20+ Mappen in den Dateien) Exceldateien inhaltlich vergleicht und mir dann möglichst die nicht übereinstimmenden Zellen(mit jeweiliger Arbeitsmappe) ausgibt und das am besten in eine separate Excel/CSV-Datei schreibt, damit ich schauen kann welcher der Einträge aktueller ist.

bisher sieht mein script so aus:

# Pfade zu den zu vergleichenden Dateien definieren

$PfadDatei1 = "X:\xyz\IP-Adressen.xlsx"

$PfadDatei2 = "X:\xyz\IP-Adressen2.xlsx"

# Excelldateien in Powershellobjekte laden

$ExcelInhalt1 = get-content -Path $PfadDatei1

$ExcelInhalt2 = get-content -Path $PfadDatei2

# Vergleichen der Excell-Inhalte

$Unterschiede = Compare-Object -ReferenceObject $PfadDatei1 -DifferenceObject $PfadDatei2

# Prüfen ob Unterschiede gefunden wurden und Ausgabe derer

if ($Unterschiede.count -eq 0)

{

   Write-Host "Keine Unterschiede gefunden"

}

else

{

   Write-Host "Unterschiede gefunden"

   $Unterschiede | Export-Csv -Path "X:\xyz\Documents\Ergebnis.csv" -NoTypeInformation -Force

}

Das Script vergleicht die Dateien zwar, gibt mir aber total kryptische Ergebnisse aus. Also als würde ich ne C++ Datei verschlüsselt im Editor öffnen

Hat jemand ne Idee was ich da ändern muss damit der mir das so ausgibt, dass ich am besten den Namen der Arbeitsmappe und die Zelle ausgegeben bekomme?

danke schon mal

Microsoft Excel, programmieren, Script, PowerShell, Office 365