I have some issue when i try to create a folder, but the same issue come out when i try create file too.

this is a sample of my code :

$web_sp = $session_sp.Web

$folder = $web_sp.GetFolderByServerRelativeUrl(($urlGed.Valeur+'/'+$ObjGed.Valeur+'/Commandes'))

# at this moment if I check $folder.ServerRelativeUrl it returns the good url so I thinks it means it's loaded correctly

$folder.Folders.Add('NewFolder') # Here no exeption

$session_sp.Load($folder) #Folder or Folder.Folders

at the last ExecuteQueryan an exception has occurred ("File not found")

(When I use the Sharepoint web page I can create folder and file so I think I have the acces rigth)


Try this:

$myNewFolder = $folder.Folders.Add('NewFolder') # Newly created folder return to $myNewFolder variable

$session_sp.Load($myNewFolder) # Load this variable for the new folder
  • Thanks for your response but i have the same result ("File not found") Exception.
    – Devtesteur
    May 16 '19 at 13:00
  • Does your expression ($urlGed.Valeur+'/'+$ObjGed.Valeur+'/Commandes') yield a correct server relative URL to the Commandes folder?
    – James Love
    May 16 '19 at 13:03
  • 1
    Yes when a verify in my web browser it's a good URL. Thanks for your help btw
    – Devtesteur
    May 16 '19 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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