Exchange 2013 - Powershell cmd error

I'm trying to set the location to search my Transport logs. I used command:

set-location (Get-TransportService).ReceiveProtocolLogPath

but get this error:

Set-Location : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Path'. Specified method is not supported.
Scotch TechITAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason CrawfordTransport NinjaCommented:
Try this:

(Get-TransportServer HOSTNAME).ReceiveProtocolLogPath.PathName
Jason CrawfordTransport NinjaCommented:
You would need to replace hostname with the actual server name
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Obviously Get-TransportServer returns data for more than one server at your location. I suppose you are running this on the edge server itself (otherwise it would not make sense), so you can indeed run something similar to what Jason posted:
set-location (Get-TransportService $env:Computername).ReceiveProtocolLogPath

Open in new window

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Jason CrawfordTransport NinjaCommented:
I don't think it's Get-TransportService, the only ReceiveProtocolLogPath property I could find was found in Get-TransportServer.  You may want to verify verbose logging is actually enabled on at least one Receive Connector.  I always enable it on all my RCs:

Get-ReceiveConnector | Set-ReceiveConnector -ProtocolLoggingLevel Verbose

At the end of the day storage is cheap and these logs have saved my a** many times so don't sweat the space requirements.
Jason CrawfordTransport NinjaCommented:
Or here's another method:

Although you'd probably have to do something like:

Set-Location $exinstall + 'TransportRoles\Logs\Hub\ProtocolLog\SmtpReceive'
Scotch TechITAuthor Commented:
Thanks. I've tried both suggestions however with Get-Server or Get-Service I still receive the error:

Set-Location : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Path'. Specified method is not supported.
Scotch TechITAuthor Commented:
I take it back, both commands worked, sorry for the confusion.

But I do not have an EDGE server, I'm running on one of the DAG members, how can i search all servers with one command without having to run for each server?
Jason CrawfordTransport NinjaCommented:
There are several ways.  Here is one:

First save the servers you want to query in the servers.txt file on your desktop and include one hostname per line then run this:

Invoke-Command -ComputerName (Get-Content "$env:USERPROFILE\Desktop\servers.txt") -ScriptBlock {
    (Get-TransportServer $env:Computername).ReceiveProtocolLogPath.PathName

Open in new window

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
It depends on what exactly you want to do. Setting the current working directory needs to be done server by server, and with additional code to execute. There are a lot of ways to do it ;-).
E.g. if executing from a single Exchange Shell window, not messing around with remote executing:
Get-TransportService |
  Select @{n='Server'; e={$_.Name}},
         @{n=RemoteLogPath; e={"\\$($_.Name)\$($_.ReceiveProtocolLogPath.PathName -replace ':', '$')"}} |
  % {
    Write-Host "Search receive log at $($_.Server)"
    Set-Location $_.RemoteLogPath
    # do your stuff here

Open in new window

This accesses the logs via UNC path. Your user needs to be able to access the c$ etc. shares of each server.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason CrawfordTransport NinjaCommented:
Ah right I forgot the whole point of this was to set the working directory.  Qlemo is right it depends largely on specifically what you're doing.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
As said above, Jason's suggestion is not really appliable to your question - you won't be able to use it as-is in conjunction with Set-Location. That requires some more code, similar to what I've used in the loop body.

Also note the comment of the Get-TransportServer help: The Get-TransportServer cmdlet will be removed in a future version of Exchange. You should use the Get-TransportService cmdlet instead..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.