Solved

Powershell Script Help

Posted on 2013-06-24
4
290 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
[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
  • 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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

A list of top three free exchange EDB viewers that helps the user to extract a mailbox from an unmounted .edb file and get a clear preview of all emails & other items with just a single click on mailboxes.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
In this video we show how to create a Contact 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 Recipients >> Contact ta…
In this video we show how to create an Address List 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 Organization >> Ad…
Suggested Courses

615 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