ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Powershell create shortcut to server root share

    IT Discussion
    powershell
    4
    9
    785
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DustinB3403D
      DustinB3403
      last edited by

      The below is what I have, and it works on my system, but not others. I had this completed >.< but I dirped, and erased the thumb drive that had the only copy.

      The goal is to create a shortcut on any given users desktop to the specified server, not to the sub-share under the root.

      IE: Target>Server1

      Not Target>Server1>Share

      $TargetFile = "\\server.domain.com"
      $ShortcutFile = "$env:Public\Desktop\FileServer.lnk"
      $WScriptShell = New-Object WScript.Shell -Verbose
      $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
      $Shortcut.TargetPath = $TargetFile
      $Shortcut.Save()
      
      dafyreD 1 Reply Last reply Reply Quote 2
      • dafyreD
        dafyre @DustinB3403
        last edited by

        @dustinb3403 said in Powershell create shortcut to server root share:

        The below is what I have, and it works on my system, but not others. I had this completed >.< but I dirped, and erased the thumb drive that had the only copy.

        The goal is to create a shortcut on any given users desktop to the specified server, not to the sub-share under the root.

        IE: Target>Server1

        Not Target>Server1>Share

        $TargetFile = "\server.domain.com"
        $ShortcutFile = "$env:Public\Desktop\FileServer.lnk"
        $WScriptShell = New-Object WScript.Shell -Verbose
        $Shortcut = $WScriptShell.CreateShortcut($ShortcutFile)
        $Shortcut.TargetPath = $TargetFile
        $Shortcut.Save()

        Do you get any error messages?

        Seems to me like your $ShorcutFile should be:

        $ShortcutFile = "$($env:Public)\Desktop\FileServer.lnk" ?

        DustinB3403D 1 Reply Last reply Reply Quote 0
        • DustinB3403D
          DustinB3403 @dafyre
          last edited by

          @dafyre said in Powershell create shortcut to server root share:

          Do you get any error messages?

          Seems to me like your $ShorcutFile should be:

          $ShortcutFile = "$($env:Public)\Desktop\FileServer.lnk" ?

          A bunch of random error messages about object not found (powershell objects).

          Gah I wish I had backed up this stupid script. .

          1 Reply Last reply Reply Quote 0
          • DustinB3403D
            DustinB3403
            last edited by

            I got it.

            $WshShell = New-Object -comObject WScript.Shell
            $Shortcut = $WshShell.CreateShortcut("$Home\Desktop\FileServer.lnk")
            $Shortcut.TargetPath = "\\server.domain.com"
            $Shortcut.Save()
            
            1 Reply Last reply Reply Quote 2
            • DustinB3403D
              DustinB3403
              last edited by

              ps. I made backup now.

              1 Reply Last reply Reply Quote 2
              • dbeatoD
                dbeato
                last edited by

                I assume you don't want to use GPO for this.

                DustinB3403D 1 Reply Last reply Reply Quote 0
                • DustinB3403D
                  DustinB3403 @dbeato
                  last edited by

                  @dbeato said in Powershell create shortcut to server root share:

                  I assume you don't want to use GPO for this.

                  Unfortunately for this case that isn't an option. Extenuating circumstances. . . .

                  1 Reply Last reply Reply Quote 1
                  • JaredBuschJ
                    JaredBusch
                    last edited by

                    @DustinB3403 what about the public desktop instead of hte user desktop?

                    Then it will always be there, regardless of who logs in.

                    DustinB3403D 1 Reply Last reply Reply Quote 2
                    • DustinB3403D
                      DustinB3403 @JaredBusch
                      last edited by

                      @jaredbusch said in Powershell create shortcut to server root share:

                      @DustinB3403 what about the public desktop instead of hte user desktop?

                      Then it will always be there, regardless of who logs in.

                      Not a huge concern for our use cases as we usually just end up wiping a system and reloading between user changes.

                      I thought about it, but it wasn't critical and as we change things around it becomes a pain to remove the old links to systems that may not exist any more.

                      1 Reply Last reply Reply Quote 1
                      • 1 / 1
                      • First post
                        Last post