Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Yes I have tried that as well, but the error remains the same:
The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
+ CategoryInfo : InvalidArgument: (@{PrimarySmtpAd...@Domain.com}:PSObject) [Get-Mailbox], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,Get-Mailbox
+ PSComputerName : PRDEX03-VM.Domain.com
$Server = 'PRDFS01-VM'
$ServerBackupUNCPath = "\\$Server\PST"
$InputCSVPath = 'C:\LOGS\Input.csv'
$ExportCSVPath = 'C:\LOGS\Output.csv'
$ExportExistsCSVPath = 'C:\LOGS\Exist.csv'
Import-PSSession ($Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://PRDEXC03-VM/Powershell/ -Authentication Kerberos)
$Users = Get-Content -Path $InputCSVPath
&{
foreach ($User in $Users) {
Write-Host "Processing.... $User"
Get-Mailbox $User.ToString() | Select PrimarySmtpAddress
}
} | Export-Csv -Path $ExportCSVPath -NoTypeInformation
Import-Csv -Path $ExportCSVPath |
ForEach-Object{Get-MailBox $_.PrimarySmtpAddress} |
% {
Write-Host "Processing .... $($_.Name) ..." -ForegroundColor Green
# Check if the file already exist or not
$FileResult = Test-Path -Path "$ServerBackupUNCPath\$($_.PrimarySmtpAddress).PST" -PathType Leaf
if ( $FileResult -ne $True ) {
#If there is no exported .PST file on the destination folder, then begin the export mailbox command and log if there any error to the AliasName.LOG file:
New-MailboxExportRequest -Mailbox $_ -FilePath "$ServerBackupUNCPath\$($_.PrimarySmtpAddress).PST" -BadItemLimit 50 -AcceptLargeDataLoss -WhatIf
} else {
Write-Output "The user $($_.PrimarySmtpAddress).PST file is already existing"
#Append the list of already existing list of users C:\LOGS\Exist.csv
Get-MailboxExportRequestStatistics -IncludeReport | Select -Expand Report | Out-File "C:\LOGS\$($_.PrimarySmtpAddress).log"
}
# I assume, whetever line I put here will be executed regardless of any of the condition above is met or not
#Remove-Mailbox -Identity $_ -Confirm $false -WhatIf
Write-Host "Removing Mailbox $($_.PrimarySmtpAddress)" -ForegroundColor Red
}
it is progressing well, however it is now stuck with the below error:
The user First.Last@domain.com.PST file is already existing cmdlet Get-MailboxExportRequestStatistics at command pipeline position 1
Supply values for the following parameters:
Identity:
looks like it is stuck in the line to export the report when the user already exists: Get-MailboxExportRequestStatistics -IncludeReport | Select -Expand Report | Out-File "C:\LOGS\$($_.PrimarySmtpAddress).log"
Import-Csv -Path $ExportCSVPath |
ForEach-Object{
# Check if the file already exist or not
if(Test-Path -Path "$ServerBackupUNCPath\$($_.PrimarySmtpAddress).PST"){
Write-Output "The user $($_.PrimarySmtpAddress).PST file is already existing"
#Append the list of already existing list of users C:\LOGS\Exist.csv
Get-MailboxExportRequestStatistics $_.PrimarySmtpAddress -IncludeReport |
Select -Expand Report |
Out-File "C:\LOGS\$($_.PrimarySmtpAddress).log"
} else {
#If there is no exported .PST file on the destination folder, then begin the export mailbox command and log if there any error to the AliasName.LOG file:
New-MailboxExportRequest $_.PrimarySmtpAddress -FilePath "$ServerBackupUNCPath\$($_.PrimarySmtpAddress).PST" -BadItemLimit 50 -AcceptLargeDataLoss -WhatIf
}
}
This topic is 5 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.