SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new in powershell, i want to save a file which powershell will automatically create new subfolder in sharepoint 2010 and save it ( the subfolder named should be todayname i.e. 25Oct2012) :

here is the script :

$sharepointsave = "SiteURL+DocumentLibrarypath" + "/" + $today + "/"

New-Item $sharepointsave -type directory -Force

$sharepointpath = "SiteURL+DocumentLibrarypath" + "/" + $today + "/"
$sharepointsave = $sharepointpath + $filename + $today + ".xls"


however, it couldn't create the subfolder ... would you please help

Thanks very much

Best Regards Mary

share|improve this question
Mary, can you please echo or Write-Host the $today variable, I think it contains some special characters which are invalid for a folder name! – Arsalan Adam Khatri Oct 25 '12 at 15:40


I think the $today variable returns some special characters with it, which are invalid for a folder name and that causes it not to create the folder...

Can you please try date formatting like:

$completeFolderName = Get-Date -format dMMMyyyy

Reference to Date Formats in Powershell

UPDATE: Here is how you create folders from PowerShell:

PS > $spFolder = $spDocumentLibrary.AddItem( 
>> "",[Microsoft.SharePoint.SPFileSystemObjectType]::Folder,"My New Folder" 
PS > $spFolder.Update()

Please refer to: Use PowerShell Cmdlets to Manage SharePoint Document Libraries

share|improve this answer
Hi, I have tried this, but it cannot create the subfolder in sharepoint (e.g. subfolder name'25Oct2012') – Mary Oct 29 '12 at 7:15
it said "Path not found" in sharepoint , so ...i guess it cannot create new subfolder... – Mary Oct 29 '12 at 7:16
Mary, I have updated the answer – Arsalan Adam Khatri Oct 29 '12 at 14:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.