Solved

Powershell Script Help

Posted on 2013-06-24
4
288 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article explains how to install and use the NTBackup utility that comes with Windows Server.
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
In this video we show how to create a Shared Mailbox 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 >> Sha…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

710 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