PowerShell mkdir temp error


Hello! I’m a beginner, working through the exercises in Learn Python 3 (in the appendix learning how to work in PowerShell). When I attempt to make a directory this is the error I receive. Would anyone know what is causing this and how to fix?

PS C:\WINDOWS\system32> cd

PS C:\WINDOWS\system32> mkdir temp
mkdir : Access to the path ‘temp’ is denied.
At line:1 char:1

  • mkdir temp
  •   + CategoryInfo          : PermissionDenied: (C:\WINDOWS\system32\temp:String) [New-Item], UnauthorizedAccessExce 
      + FullyQualifiedErrorId : CreateDirectoryUnauthorizedAccessError,Microsoft.PowerShell.Commands.NewItemCommand

PS C:\WINDOWS\system32>


Try this:

cd ~ 

which should take you to something like this:


then try mkdir temp again, see if that works.


Yep, @zberwaldt is right. The reason you can’t make a file there is your account isn’t allowed to modify that directory since it’s a sensitive system directory. I have no idea why microsoft insists on defaulting to that directory, but just remember to cd ~ to go home.