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

    snapin script running on a samba share

    Scheduled Pinned Locked Moved
    Windows Problems
    3
    5
    511
    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.
    • L
      lebrun78
      last edited by

      Hello
      Do you have any suggestions or examples of snapins running powershell scripts for installing programs hosted on an authenticated share?
      I am unable to do an authenticated samba mount with the system account used by the fog client.

      Fog Version: Fog 1.5.10
      Server OS: AlmaLinux release 8.8

      george1421G 1 Reply Last reply Reply Quote 0
      • S
        Sebastian Roth Moderator
        last edited by

        @lebrun78 You might want to share the script you have so far so we know more about what exactly you are trying to do.

        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

        L 1 Reply Last reply Reply Quote 0
        • george1421G
          george1421 Moderator @lebrun78
          last edited by

          @lebrun78 If I remember right, the fog client runs as SYSTEM which has not rights outside the local box its running on. So you will need to map a drive in your script and provide new credential to connect to that external share. This is the same for a samba or cifs share. SYSTEM only has local rights.

          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!

          1 Reply Last reply Reply Quote 0
          • L
            lebrun78 @Sebastian Roth
            last edited by lebrun78

            @sebastian-roth

            Here is the content of the fog_snapin_inst.ps1 script which mounts the share and which launches either a batch script or a powershell script

            param (
                [String] $programme
            )
            $user = "fog"
            $pwd = "EncriptpasswordwBiADEAZA="
            
            $serveur = "\\wolala.univ-rennes1.fr\snapins$"
            [Byte[]] $key = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)
            $password = ConvertTo-SecureString -key $key -string $pwd
            $credential = New-Object -TypeName system.management.Automation.PSCredential -ArgumentList $user, $password
            
            if (!(Test-Path -Path Q:)){
                $net = new-object -ComObject WScript.Network
                $net.MapNetworkDrive("p:", $serveur, $false, $credential.GetNetworkCredential().UserName,$credential.GetNetworkCredential().password)
               
            }
            
            #lorsque l'on lance un script powershell, si il y avait des espaces dans le nom, cela ne passait pas 
            #lorsque l'on faisait un start-process et ce nom en argument. Donc on utilise plutot le nom court
            $prog_court = (New-Object -ComObject Scripting.FileSystemObject).GetFile($programme).ShortPath
            
            					
                write-host "$(hostname):Dossier de l'installer $($dossier_installer)"
            	write-host ""
            	write-host "$(hostname):lancement de $($programme)"
                write-host "$(hostname):lancement de $($prog_court)"
            
            #start-process -FilePath $programme -wait -NoNewWindow
            $dossier_installer = $((get-item -path $programme).DirectoryName)
            
            if (!(Test-Path -Path "$dossier_installer\logs_fog_install")){New-Item -ItemType directory -Path "$dossier_installer\logs_fog_install"}
            $extension = (get-item -path $programme).Extension
            if ($extension -eq ".bat" -or $extension -eq ".cmd") {
            	write-host "$env:COMPUTERNAME:C'est un script bat"
            	start-process -FilePath $prog_court -wait -NoNewWindow -RedirectStandardOutput ${dossier_installer}\logs_fog_install\${env:COMPUTERNAME}_log.txt -RedirectStandardError ${dossier_installer}\logs_fog_install\${env:COMPUTERNAME}_error.txt
                
            }
            if ($extension -eq ".ps1") {
            	write-host "$env:COMPUTERNAME:C'est un script powershell"
            	$policy = Get-ExecutionPolicy
            	Set-ExecutionPolicy AllSigned
            	start-process -FilePath PowerShell -Arg $prog_court -wait -NoNewWindow -RedirectStandardOutput ${dossier_installer}\logs_fog_install\${env:COMPUTERNAME}_log.txt -RedirectStandardError ${dossier_installer}\logs_fog_install\${env:COMPUTERNAME}_error.txt
                Set-ExecutionPolicy $policy
            }
            
            
            $net.RemoveNetworkDrive("p:")
            Remove-SmbMapping -RemotePath $serveur -Force
            
            
            # SIG # Begin signature block
            # MIIECAYJKoZIhvcNAQcCoIID+TCCA/UCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
            

            So I get this Snapin Command read-only:

            powershell.exe -ExecutionPolicy Bypass -NoProfile -File fog_snapin_inst.ps1 -programme P:\officepro2010\inst_office2010.bat
            

            Fog Version: Fog 1.5.10
            Server OS: AlmaLinux release 8.8

            1 Reply Last reply Reply Quote 0
            • S
              Sebastian Roth Moderator
              last edited by

              @lebrun78 Can you run this exact script in the SYSTEM context (as described below through PsExec) and see where exactly it fails?

              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
              • First post
                Last post

              157

              Online

              12.0k

              Users

              17.3k

              Topics

              155.2k

              Posts
              Copyright © 2012-2024 FOG Project