Solved

Exchange Powershell Help

Posted on 2014-10-22
7
106 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
Is Your AD Toolbox Looking More Like a Toybox?

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.

 

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 69

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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 …
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

773 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