pixel0815
Goto Top

Keine Methode mit dem Namen op Addition beim Ausführen eines PS Skriptes

Moin moin zusammen,

ich würde gerne das unten stehende Skript ausführen, allerdings funktioniert es nicht mehr seit Windows 2012 R2.
Ich bekomme folgende Meldung

Fehler beim Aufrufen der Methode, da [System.Management.Automation.PSObject] keine Methode mit dem Namen "op_Addition" enthält.  

Es liegt wohl an dem New-Object PSObject -Property, allerdings steige ich da nicht durch weshalb es nicht mehr richtig funktioniert.

Eigentlich sollte eine laaange Liste da erstellt werden. Hilfe ;-( Ich würde mich freuen wenn mir jemand helfen kann.
Ich setze auf dem Server folgende Version der PS ein
Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1      

[void][System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c")   
# get local farm
Add-PSSnapin Microsoft.SharePoint.PowerShell
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
# get web services from local farm
$websrvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
# format for .csv file output
$outputToCSV = @()
function CheckedOutItems()
{
    # get all web services available in the farm   
    foreach ($websrvc in $websrvcs) {
        # retrieve web applications
        foreach ($webApp in $websrvc.WebApplications) {
            # now get site collections from the web application
            foreach ($site in $webApp.Sites) {
                # process each web site
                Try {
                    foreach ($web in $site.AllWebs) {
                         $siteUrl = $web.Url
                         $siteName = $web.Title
                         $siteUserCnt = $web.AllUsers.Count
                         $PimarySiteAdmin = $site.Owner.Name
                         $SecondarySiteAdmin = $site.SecondaryContact.Name
                         $siteusage = $site.Usage.Storage/1MB
                         $Hits = $site.Usage.Hits                       
                         $Created = [datetime]$web.Created
                         $LastModified = $Web.LastItemModifiedDate
                         $SnapShot = (get-date)
                         $LastUpdate = ($SnapShot – [datetime]$LastModified)

                         $outputToCSV += New-Object PSObject -Property @{"Site Title" = $siteName; "Url" = $siteUrl; "Primary site collection admin"= $PimarySiteAdmin;   
                                                                        "Secondary site collection admin"=$SecondarySiteAdmin; "Total Users" =$siteUserCnt;"Size" = $siteusage;   
                                                                        "Date Last Modified" = $LastModified; "Days Last Update" = $LastUpdate; "Hits" =$Hits; "Date Created" =$Created  
                                                                        }
                                        $file_date = get-date -format M-d-yyyy
                                        $file_name = "$env:USERPROFILE\Desktop\NoCheckedInVersion"+ $file_date + ".csv"  
                                        $outputToCSV | ConvertTo-Csv -notype > $file_name

                } # end $site.AllWebs loop
            } # end Try statement 
            # General catch exceptions
            Catch {
                    "General Exceptions caught: " >> "$env:USERPROFILE\Desktop\errorlog.txt"  
                    $_.Exception.Message >> "$env:USERPROFILE\Desktop\errorlog.txt"  
            }# end general catch statement
            }
        }
    }
}
# Make a call to the function
CheckedOutItems

Content-Key: 345591

Url: https://administrator.de/contentid/345591

Ausgedruckt am: 29.03.2024 um 08:03 Uhr

Mitglied: pixel0815
pixel0815 07.08.2017 um 12:46:39 Uhr
Goto Top
Ich hab auch mal dieses Versucht

$Output = New-Object System.Object
    $Output | Add-Member -Membertype NoteProperty -Name "Site Title" -Value "$siteName"  
    $Output | Add-Member -Membertype NoteProperty -Name "Primary site collection admin" -Value "$PimarySiteAdmin"  
    $Output | Add-Member -Membertype NoteProperty -Name "Secondary site collection admin" -Value "$SecondarySiteAdmin"  
    $Output | Add-Member -Membertype NoteProperty -Name "Total Users" -Value "$siteUserCnt"  
    $Output | Add-Member -Membertype NoteProperty -Name "Size" -Value "$siteusage"  
    $Output | Add-Member -Membertype NoteProperty -Name "Date Last Modified"  -Value "$LastModified"  
    $Output | Add-Member -Membertype NoteProperty -Name "Days Last Update" -Value "$LastUpdate"  
    $Output | Add-Member -Membertype NoteProperty -Name "Hits"  -Value "$Hits"  
    $Output | Add-Member -Membertype NoteProperty -Name "Date Created"  -Value "$Created"  

    $outputToCSV += $Output
                                        $file_date = get-date -format M-d-yyyy
                                        $file_name = "$env:USERPROFILE\Desktop\NoCheckedInVersion"+ $file_date + ".csv"  
                                        $outputToCSV # | ConvertTo-Csv -notype > $file_name

Leider bekomme ich dieselbe Meldung.
Mitglied: 133883
133883 09.08.2017 aktualisiert um 11:43:37 Uhr
Goto Top
Klammern
$outputToCSV += (New-Object PSObject -Property @{"Site Title" = $siteName; "Url" = $siteUrl; "Primary site collection admin"= $PimarySiteAdmin;"Secondary site collection admin"=$SecondarySiteAdmin; "Total Users" =$siteUserCnt;"Size"=$siteusage;"Date Last Modified" = $LastModified; "Days Last Update" = $LastUpdate; "Hits" =$Hits; "Date Created"=$Created})  
oder stattdessen [pscustomobject] verwenden das ist seit PS 3.0 sowieso viel schneller
$outputToCSV += [pscustomobject] @{"Site Title" = $siteName; "Url" = $siteUrl; "Primary site collection admin"= $PimarySiteAdmin;"Secondary site collection admin"=$SecondarySiteAdmin; "Total Users" =$siteUserCnt;"Size"=$siteusage;"Date Last Modified" = $LastModified; "Days Last Update" = $LastUpdate; "Hits" =$Hits; "Date Created"=$Created}  
Mitglied: pixel0815
pixel0815 09.08.2017 um 16:58:09 Uhr
Goto Top
Das probiere ich morgen gleich aus face-smile))) Danke!
Mitglied: pixel0815
pixel0815 10.08.2017 um 08:38:56 Uhr
Goto Top
Funktioniert nicht. Erhalte weiterhin die Meldung:

General Exceptions caught:
Fehler beim Aufrufen der Methode, da [System.Management.Automation.PSObject] keine Methode mit dem Namen "op_Addition" enthält.
Mitglied: 133883
133883 10.08.2017 um 08:43:57 Uhr
Goto Top
Dann hat deine PS einen Knacks!