Solved

Exchange Powershell Help

Posted on 2014-10-22
7
111 Views
Last Modified: 2014-10-27
How can i retreive only the value "Calendrier" when running this command

[PS] C:\Windows\system32>$FolderPath = Get-MailboxFolderStatistics -Identity sallenpq -FolderScope Calendar | fl FolderP
ath
[PS] C:\Windows\system32>$FolderPath


FolderPath : /Calendrier

Thanks !
0
Comment
Question by:jfguenet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 12

Expert Comment

by:David Paris Vicente
ID: 40398295
Copy the code to the notepad, and save the file with an extension PS1.
Example: folderpath.ps1


$FolderPath = Get-MailboxFolderStatistics -Identity sallenpq -FolderScope Calendar | fl FolderPath
write-host $FolderPath

Open in new window


Then run it from the powershell line

Hope it helps
0
 

Author Comment

by:jfguenet
ID: 40399323
No but i need only the value "Calendrier" not "FolderPath : /Calendrier"
0
 
LVL 12

Expert Comment

by:David Paris Vicente
ID: 40399431
Can you explain what you want to accomplish?

Meanwhile take a look on the following code.


get-mailboxfolderstatistics myusername | where {$_.name -match "Inbox|Deleted|Sent|Calendar|Drafts"} | sort-object Name | ft Name, FolderPath, ItemsInFolder, FolderSize -auto

Open in new window

0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:jfguenet
ID: 40399443
When i run this command

[PS] C:\Windows\system32>$FolderPath = Get-MailboxFolderStatistics -Identity sallenpq -FolderScope Calendar | fl FolderPath

and then run this
[PS] C:\Windows\system32>$FolderPath

i get this value
FolderPath : /Calendrier

I want to trim the value "FolderPath : /Calendrier" to get the value "Calendrier"

Thanks !
0
 
LVL 12

Expert Comment

by:David Paris Vicente
ID: 40399477
$FolderPathTrim=$FolderPath.Trim("FolderPath : /")

[PS] C:\Windows\system32>$FolderPathTrim

Open in new window


let us know if this do the trick.

regards
0
 
LVL 70

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40401834
You've been confused by the format-list output. Remember that every value in PowerShell is part of an object, and as such is the value of a property. Even strings and numeric values are (simple) objects.

Never use the output of format-* for further processing. Formatting is done as last action before displaying results.

What you want to do is one of the following lines:
$FolderPath = Get-MailboxFolderStatistics -Identity sallenpq -FolderScope Calendar | select -Expand FolderPath
$FolderPath = (Get-MailboxFolderStatistics -Identity sallenpq -FolderScope Calendar).FolderPath.ToString()

Open in new window

if you insist in loosing all properties of the result, and only have the path as string.
0
 

Author Closing Comment

by:jfguenet
ID: 40406299
Thanks that is what i was looking for
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
A procedure for exporting installed hotfix details of remote computers using powershell
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question