• Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
  • Recent
  • Unsolved
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Snapin issue - using powershell to copy items

Scheduled Pinned Locked Moved Unsolved
FOG Problems
4
14
559
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.
  • R
    rodluz Developer
    last edited by Aug 15, 2023, 7:15 PM

    @anwoke8204 Tom is right. I had that same issue when trying to use snapins the first time.
    You would need to do something like this:

    $username = "DOMAIN\USERNAME""
    $password = ConvertTo-SecureString "PASSWORD!" -AsPlainText -Force
    $creds = New-Object System.Management.Automation.PSCredential $username, $password
    
    New-PSDrive -Persist -Name "Z" -PSProvider FileSystem -Root "\\SHARE\PATH" -Credential $creds
    
    #
    # RUN YOUR CODE REFERENCING THE "Z" DRIVE
    #
    
    Remove-PSDrive -Name "Z"
    
    D 1 Reply Last reply Aug 16, 2023, 6:09 AM Reply Quote 0
    • D
      dellborg82 @rodluz
      last edited by dellborg82 Aug 16, 2023, 12:24 AM Aug 16, 2023, 6:09 AM

      Hello @rodluz

      I made the changes (see below) It runs like expected when run FROM the machine; however, when running through FOG it still says running, then immediately completed, and nothing is copied. Ideas here? Log just shows completed. But the folder is empty

      cls

      $username = “starshipfrontier\wbadmin”
      $password = ConvertTo-SecureString “USSWhiteBuffalo33247” -AsPlainText -Force
      $creds = New-Object System.Management.Automation.PSCredential $username, $password
      $NetworkPath = “\starbase\Artemis_Files\Artemis Versions\Mod\Artemis 2.8 TNG Mod”
      $LocalPath = “C:\Artemis 2.8 TNG Mod”

      #New-PSDrive -Name Artemis -PSProvider FileSystem -Root “\starbase\Artemis_Files\Artemis Versions\Mod\Artemis 2.8 TNG Mod” -Credential $creds
      New-PSDrive -Name “S” -Root $NetworkPath -PSProvider “FileSystem” -Credential $cred
      #Get-PSDrive -Name “S”

      RUN YOUR CODE REFERENCING THE “Z” DRIVE

      Write-Host “Copying Artemis to Local Computer” -ForegroundColor DarkCyan

      if(Test-Path $LocalPath) {“Temp folder found”} else {New-Item -ItemType Directory -Force -Path $LocalPath}

      New-Item -ItemType Directory -Force -Path $LocalPath
      Copy-Item S:* -Destination $LocalPath -Recurse -Force

      Write-Host “Copy Complete” -ForegroundColor DarkCyan
      Remove-PSDrive -Name “S”

      T 1 Reply Last reply Aug 16, 2023, 10:08 AM Reply Quote 0
      • T
        Tom Elliott @dellborg82
        last edited by Tom Elliott Aug 16, 2023, 8:08 AM Aug 16, 2023, 10:08 AM

        @dellborg82 You seem to have a typo, that or because it’s not in code format (triple back ticks) we’re losing context.

        Your script should be:

        $NetworkPath = "\\starbase\Artemis_Files\Artemis Versions\Mod\Artemis 2.8 TNG Mod"
        $LocalPath = "C:\Artemis 2.8 TNG Mod"

        $username = "starshipfrontier\wbadmin"
        $password = ConvertTo-SecureString "USSWhiteBuffalo33247" -AsPlainText -Force
        $creds = New-Object System.Management.Automation.PSCredential $username, $password

        New-PSDrive -Name "S" -Root $NetworkPath -PSProvider "FileSystem" -Credential $cred

        If (-Not (Test-Path $LocalPath)) {
        Write-Host "Creating $LocalPath" -ForegroundColor DarkCyan
        New-Item -ItemType Directory -Force $LocalPath
        }

        Write-Host "Copying Artemis to Local Computer" -ForegroundColor DarkCyan
        Copy-Item S:\* -Destination $LocalPath -Recurse -Force

        Write-Host "Copy Complete" -ForegroundColor DarkCyan
        Remove-PSDrive -Name "S"

        Why it’s not showing the full appropriately lined strings I don’t know.

        7f42e8ea-4bbc-4b6c-a8a0-a744774348ff-image.png

        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

        D 1 Reply Last reply Aug 16, 2023, 1:48 PM Reply Quote 0
        • D
          dellborg82 @Tom Elliott
          last edited by Aug 16, 2023, 1:48 PM

          Hello @Tom-Elliott, Thanks for your help here; however, it’s still not working and when I run it locally, I get the below error on New-PSDrive

          fe8924d7-ffa1-4fbb-8f0e-a8ac2c603152-image.png

          I’m not the best at PowerShell, but have been learning here and there.

          Please Advise where this may be going wrong. Unless I’m Mistaken (and I likely am) is this being caused by the $credIf (-Not (Test-Path $LocalPath)) part of the script?

          T 1 Reply Last reply Aug 16, 2023, 2:06 PM Reply Quote 0
          • T
            Tom Elliott @dellborg82
            last edited by Aug 16, 2023, 2:06 PM

            @dellborg82 I printed the actual code as an image in my post because for some reason the code syntax is joining lines in appropriately here.

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            D 1 Reply Last reply Aug 16, 2023, 2:16 PM Reply Quote 0
            • D
              dellborg82 @Tom Elliott
              last edited by Aug 16, 2023, 2:16 PM

              @Tom-Elliott Thanks for clarifying that.

              I’m not sure why I didn’t catch that. Trying now. (It ran locally, just fine); however, run run via FOG, The pop up comes up that says it’s running, 3 seconds later, popup shows it’s complete (this is what we’ve been seeing)

              I check the folder… empty

              T 1 Reply Last reply Aug 16, 2023, 4:49 PM Reply Quote 0
              • T
                Tom Elliott @dellborg82
                last edited by Aug 16, 2023, 4:49 PM

                @dellborg82 Can you look at the event logs and see if anything shows up for that timeframe that the script actually runs.

                Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                D 1 Reply Last reply Aug 17, 2023, 12:18 AM Reply Quote 0
                • D
                  dellborg82 @Tom Elliott
                  last edited by Aug 17, 2023, 12:18 AM

                  @Tom-Elliott Here’s the log file from C:\fog.txt. As far as I can tell, (again I could be wrong) but it looks like the log shows it’s running.


                  8/16/2023 5:14:14 PM Client-Info Client Version: 0.13.0
                  8/16/2023 5:14:14 PM Client-Info Client OS: Windows
                  8/16/2023 5:14:14 PM Client-Info Server Version: 1.5.10.10
                  8/16/2023 5:14:14 PM Middleware::Response Success
                  8/16/2023 5:14:14 PM SnapinClient Running snapin Copy Current Artemis
                  8/16/2023 5:14:14 PM Middleware::Communication Download: https://10.4.47.15/fog/service/snapins.file.php?mac=5C:51:4F:AB:0E:92|5E:51:4F:AB:0E:91|18:A9:9B:FD:A2:71|5C:51:4F:AB:0E:91|5C:51:4F:AB:0E:95&taskid=178
                  8/16/2023 5:14:15 PM SnapinClient C:\Program Files (x86)\FOG\tmp\Copy_Current_Artemis_V3.ps1
                  8/16/2023 5:14:15 PM Bus Emmiting message on channel: Notification
                  8/16/2023 5:14:15 PM SnapinClient Starting snapin
                  8/16/2023 5:14:18 PM SnapinClient Snapin finished
                  8/16/2023 5:14:18 PM SnapinClient Return Code: 0
                  8/16/2023 5:14:18 PM Bus Emmiting message on channel: Notification
                  8/16/2023 5:14:18 PM Middleware::Communication URL: https://10.4.47.15/fog/service/snapins.checkin.php?taskid=178&exitcode=0&mac=5C:51:4F:AB:0E:92|5E:51:4F:AB:0E:91|18:A9:9B:FD:A2:71|5C:51:4F:AB:0E:91|5C:51:4F:AB:0E:95&newService&json

                  But still nothing in the C:\Artemis 2.8 TNG Mod Directory. The directory gets created, but it’s empty.

                  D 1 Reply Last reply Aug 18, 2023, 6:12 AM Reply Quote 0
                  • D
                    dellborg82 @dellborg82
                    last edited by Aug 18, 2023, 6:12 AM

                    @Tom-Elliott

                    Is this what you were looking for?

                    D 1 Reply Last reply Aug 22, 2023, 4:16 AM Reply Quote 0
                    • D
                      dellborg82 @dellborg82
                      last edited by Aug 22, 2023, 4:16 AM

                      @dellborg82 @Tom-Elliott Thanks for your help here, I was able to figure out the issue with your guidance. I’m not 5/5 on successful copies via PowerShell.

                      T 1 Reply Last reply Aug 22, 2023, 10:04 AM Reply Quote 0
                      • T
                        Tom Elliott @dellborg82
                        last edited by Aug 22, 2023, 10:04 AM

                        @dellborg82 What was the issue? This way somebody else who may be having a similar issue can also be helped?

                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        1 / 1
                        • First post
                          13/14
                          Last post

                        229

                        Online

                        12.0k

                        Users

                        17.3k

                        Topics

                        155.2k

                        Posts
                        Copyright © 2012-2024 FOG Project