Hi,
currently i have installed powershell 1.0 on top of XP SP3 and trying to execute exchange cmdlets remotely using following script but it is giving following error.
Active Directory server vanguard.itsmenabler.co.in is not available. Error message: The supplied credential is invalid. + CategoryInfo : NotSpecified: (0:Int32) [Get-MailboxServer], ADOperationException + FullyQualifiedErrorId : EB633F97,Microsoft.Exchange.Management.SystemConfigurationTasks.GetMailboxServer
Script: takes servername username and password as arguments.
function Get-PassCred {
$pass = ConvertTo-SecureString -force -AsPlainText -string $password
$return = New-Object System.Management.Automation.PSCredential -ArgumentList $username ,$pass
$return
}
function Get-Connection {
$return = new-pssession -ComputerName $hostname -credential $cred
$return
}
function Get-Data{
#invoke-command -ComputerName $hostname -credential $cred -scriptblock {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin}
invoke-command -session $mysession -scriptblock {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin;get-wmiobject win32_computersystem;get-queue;get-mailboxserver;Remove-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin}
#invoke-command -ComputerName $hostname -credential $cred -scriptblock {Remove-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin}
}
function Disconnect-Session{
remove-pssession -session (get-pssession)
}
$hostname = $args[0]
$username = $args[1]
$password = $args[2]
$cred = Get-PassCred
#$cred | Out-Host
$mysession = Get-Connection
Get-Data
#$error
Disconnect-Session
# Set-User Administrator -RemotePowerShellEnabled $true;
# | Export-Clixml e:\exchange.xml -noclobber