Solved

Exchange Powershell Help

Posted on 2014-10-22
7
103 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
  • 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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 68

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now