PowerShell mkdir temp error


#1

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 
     ption
      + FullyQualifiedErrorId : CreateDirectoryUnauthorizedAccessError,Microsoft.PowerShell.Commands.NewItemCommand
    
    
    

PS C:\WINDOWS\system32>


#2

Try this:

cd ~ 

which should take you to something like this:

C:\user\your-username>

then try mkdir temp again, see if that works.


#3

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.