Solved

Powershell Script Help

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this video we show how to create a User 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 >> Mailb…
In this video we show how to create an Accepted Domain 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 >> Ac…

708 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

18 Experts available now in Live!

Get 1:1 Help Now