Fix $Profile default location Issue

Welcome Forums General PowerShell Q&A Fix $Profile default location Issue

  • This topic has 3 replies, 2 voices, and was last updated 1 month ago by
    Participant
    .
Viewing 3 reply threads
  • Author
    Posts
    • #223677
      Participant
      Topics: 1
      Replies: 1
      Points: 22
      Rank: Member

      I try to get $profile default location and try to create folder to build own module as below.

      $moduleFolder = $env:PSModulePath.Split(';')[0]
      mkdir "$modulesFolder\SqlAutomation"
      

      But folder ‘SqlAutomation’ getting created in C:\ drive rather $Profile default folder. I did verify path using Test-Path for all of 4 $profiles  and all come with ‘True’.

      I try to add location in .ps1 file as

      set-location C:\Users\sonny\Documents\WindowsPowerShell\Modules

      Further Info…

      C:\Users\sonny\Documents\WindowsPowerShell\Modules> $env:PSModulePath.Split(';')
      C:\Users\swarn\Documents\WindowsPowerShell\Modules
      C:\Program Files\WindowsPowerShell\Modules
      C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
      C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules
      C:\Users\sonny\Documents\WindowsPowerShell\Modules> $moduleFolder
      C:\Users\swarn\Documents\WindowsPowerShell\Modules

      I have searched net for solution but no luck… looking for help

      Thanks in advance

      • This topic was modified 1 month ago by SqlHoncho.
      • This topic was modified 1 month ago by SqlHoncho.
      • This topic was modified 1 month ago by SqlHoncho.
    • #223689
      Participant
      Topics: 4
      Replies: 2249
      Points: 5,494
      Helping Hand
      Rank: Community MVP

      sonny, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.

      When you post code or error messages or sample data or console output format it as code, please.
      In the “Text” view you can use the code tags “PRE“, in the “Visual” view you can use the format template “Preformatted“. You can go back edit your post and fix the formatting – you don’t have to create a new one.
      Thanks in advance.

      You have a typo in your mkdir command … $modulesFolder instead of $moduleFolder.

    • #223959
      Participant
      Topics: 1
      Replies: 1
      Points: 22
      Rank: Member

      Olaf, Thanks for help good spotting… I tried to fix the entry as per your nstructions… hope should be fine otherwise do let me know ad I will fix it.

      I am newbie in PowerShell domain… been watching videos and read articles on Microsoft and other experts include dbatools ones.

      My background on Windows platform so will take bit of time to get use of writing code on command line platform to avoid such syntax mistake…

      I am try to write install SSMS on SQL server… appreciate referencs/guideness if you can help with.

      Cheers

      • This reply was modified 1 month ago by SqlHoncho.
    • #224088
      Participant
      Topics: 4
      Replies: 2249
      Points: 5,494
      Helping Hand
      Rank: Community MVP

      Olaf, Thanks for help good spotting… I tried to fix the entry as per your nstructions… hope should be fine otherwise do let me know ad I will fix it.

      That’s just fine. Thanks.

      I am newbie in PowerShell domain… been watching videos and read articles on Microsoft and other experts include dbatools ones.

      You could make your life easier by using VSCode as your script editor. That would alert you about this kind of errors/mistakes.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.