I used some PowerShell code to create a new folder on a custom list where I have folders enabled. The strange thing I cant seem to figure out is that the Folder in the list seems to have two properties "name" that displays in the properties pages and URL and "title" that displays in the list view.
In the screen shots below is what my result is so I was just looking to better understand what is going on so that I can also update the folder display title as well.
(Outside folder created with PowerShell)
(Inside folder created with PowerShell)
By the way the URL's for this ended up working out fine (site/Lists/test1/Root-Folder)
Here is a sample of the code I used so far:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
# Get Site
$Site = Get-SPSite -Identity "https://spSite.com/sites/";
## Get Web <web url>
$Web = $Site.OpenWeb("site1");
## Get List <list name>
$list = $Web.Lists["test1"];
if($list) #Check If List exists!
{
# Create a Folder "Root-Folder"
# Check Folder Doesn't exists in the Library!
$folder = $list.ParentWeb.GetFolder($list.RootFolder.Url + "/" +"Root- Folder");
if ($folder.Exists -eq $false)
{
#Create a Folder
$folder = $list.AddItem("", [Microsoft.SharePoint.SPFileSystemObjectType]::Folder, "Root-Folder")
$folder.Update();
}
#Create a Sub-Folder "Sub-Folder" inside "Root-Folder"
#Check if sub-folder doesn't exists already
$Subfolder = $list.ParentWeb.GetFolder($folder.URL + "/" + "Sub-Folder");
if ($Subfolder.Exists -eq $false)
{
#Create a Sub-Folder Inside "Root-Folder"
$Subfolder = $list.AddItem($folder.URL, [Microsoft.SharePoint.SPFileSystemObjectType]::Folder, "Sub-Folder")
$Subfolder.Update();
}
}
Also on a side note if I manually edit and save the folder in SharePoint after the fact the issue goes away.

