Solved

Exchange Powershell Help

Posted on 2014-10-22
7
105 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

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

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
Synchronize a new Active Directory domain with an existing Office 365 tenant
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

912 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

24 Experts available now in Live!

Get 1:1 Help Now