Solved

Powershell Script Help

Posted on 2013-06-24
4
283 Views
Last Modified: 2013-06-24
Not a powershell script expert need some help.



trying to create the folder path on the export-mailbox command below so that file filename is journal-06212013.pst   as an example

$today = Get-Date -Format "MMddyyyy"
$Folder = M:\emai\journal\journal-$today.pst



The term 'M:\emai\journal\journal-$today' is not recognized as the name of a cmdlet, func
tion, script file, or operable program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.
At C:\Util\testdate.ps1:2 char:41
+ $Folder = M:\emai\journal\journal-$today <<<< 
    + CategoryInfo          : ObjectNotFound: (M:\emai\journal\journal-$today:String) []
   , CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 

______________________________________________________________________________________


Export-Mailbox –Identity journal -PSTFolderPath $folder -StartDate $((Get-date).AddDays(-7)) –EndDate $(Get-date) -DeleteContent


What am I not doing right here?
0
Comment
Question by:Thomas Grassi
  • 2
  • 2
4 Comments
 
LVL 40

Expert Comment

by:Subsun
ID: 39273324
File name should be in quotes..
$Folder = "M:\emai\journal\journal-$today.pst"

Open in new window

0
 
LVL 23

Author Comment

by:Thomas Grassi
ID: 39273389
Thanks that was it.

now can I do this  "$folder.pst"

Export-Mailbox –Identity journal -PSTFolderPath "$folder.pst" -StartDate $((Get-date).AddDays(-7)) –EndDate $(Get-date) -DeleteContent
0
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39273405
$Folder = "M:\emai\journal\journal-$today.pst"

Here you already added the .pst part.. so you don't have to use "$folder.pst"


Or you can assign the file name without extension
$Folder = "M:\emai\journal\journal-$today"

then use "$folder.pst" in command..
0
 
LVL 23

Author Closing Comment

by:Thomas Grassi
ID: 39273429
thanks
0

Featured Post

Why won’t your email signature format correctly?

Struggling to get your corporate email signatures to format correctly? Does the logo keep resizing? Is the text appearing too big? What can you do to prevent this? Find out how you can save your signatures today.

Question has a verified solution.

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

MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
To show how to create a transport rule in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Rules tab.:  To cr…
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…

910 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

20 Experts available now in Live!

Get 1:1 Help Now