Solved

Powershell Script Help

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Read this checklist to learn more about the 15 things you should never include in an email signature.
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

776 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