Quantcast
Channel: PowerShell App Deployment Toolkit
Viewing all 2341 articles
Browse latest View live

New Post: Command line arguments for Deploy-Application.EXE

$
0
0
You'd have to edit the WiseScript yourself. You can specify different Deploy-Application.ps1 scripts but not what you're looking for.

For the repair, you can use Get-InstalledApplication to get the product code of existing app and Execute-MSI function to run repair.

Commented Unassigned: Failed to grab execution mutex [87]

$
0
0
"Failed to grab execution mutex. System error 258." Latest Version Release Notes for 3.2.0: "Added a check for in-progress MSI installations preventing an MSI from installing and waits up to 10 minutes - this reduces instances of MSI error code 1618 (Test-MsiExecMutex)"
by mniccum
Comments: System error 258 = The wait operation timed out. But is it a "real error" or just info as in "I waited more than 10 minutes and tried again." Without mniccum's logs we can tell.

New Post: Test-VPNConnection Function: Need help testing to see if it works reliably in other environments

$
0
0
My company uses Microsoft DirectAccess for VPN connectivity. Your script does not detect an active VPN on my system. Output is below. Hope this helps:
All network adapters:

DNSDomain DefaultIPGateway DHCPServer  IPEnabled PhysicalAdapter Manufacturer      Description
--------- ---------------- ----------  --------- --------------- ------------      -----------
                                           False            True Intel Corporation Intel(R) 82579LM Gigabit Network
                                                                                   Connection
                                           False           False Microsoft         Microsoft Kernel Debug Network
                                                                                   Adapter
          {192.168.1.1}    192.168.1.1      True            True Broadcom          Dell Wireless 1504 802.11b/g/n
                                                                                   (2.4GHz)
                                           False           False Microsoft         Microsoft Wi-Fi Direct Virtual
                                                                                   Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False Microsoft         Bluetooth Device (Personal Area
                                                                                   Network)
                                            True           False VMware, Inc.      VMware Virtual Ethernet Adapter for
                                                                                   VMnet1
                                           False           False                   Microsoft Teredo Tunneling Adapter
                                           False           False Microsoft         Microsoft IP-HTTPS Platform Adapter
                                           False           False                   WAN Miniport (SSTP)
                                           False           False                   WAN Miniport (IKEv2)
                                           False           False                   WAN Miniport (PPPOE)
                                           False           False                   WAN Miniport (PPTP)
                                           False           False                   WAN Miniport (L2TP)
                                           False           False                   WAN Miniport (IP)
                                           False           False                   WAN Miniport (IPv6)
                                           False           False                   WAN Miniport (Network Monitor)
                                           False           False                   RAS Async Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False Microsoft         Microsoft ISATAP Adapter
                                            True           False VMware, Inc.      VMware Virtual Ethernet Adapter for
                                                                                   VMnet8
                                           False           False Microsoft         Microsoft ISATAP Adapter
                                           False           False Microsoft         Microsoft ISATAP Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False                   Microsoft ISATAP Adapter



Filtered to possible VPN network adapters:

DNSDomain DefaultIPGateway DHCPServer IPEnabled PhysicalAdapter Manufacturer Description
--------- ---------------- ---------- --------- --------------- ------------ -----------
                                          False           False Microsoft    Microsoft Wi-Fi Direct Virtual Adapter
                                          False           False              Microsoft Teredo Tunneling Adapter
                                          False           False Microsoft    Microsoft IP-HTTPS Platform Adapter
                                          False           False              WAN Miniport (SSTP)
                                          False           False              WAN Miniport (IKEv2)
                                          False           False              WAN Miniport (PPTP)
                                          False           False              WAN Miniport (L2TP)



Filtered to possible VPN network adapters (IP Enabled):

VPN Connection Not Detected

New Post: Test-VPNConnection Function: Need help testing to see if it works reliably in other environments

$
0
0
Thanks for testing Paul. From the posted results, I am seeing three network adapters which are IP Enabled (have network connection). Two are from VMWare and one is a physical device so cannot be a VPN connection. Did you run the script while you were connected to VPN? The script can only detect the adapter used for VPN connection when connected to VPN. I have updated the code above with a few modifications. Please run it again when connected to VPN and let me know the results. Also, if you know the name of the adapter that the VPN connection uses, that would be great because then I don't have to try and guess if the detection is not working.

New Post: Test-VPNConnection Function: Need help testing to see if it works reliably in other environments

$
0
0
Still not showing that it is connected. And yes I am connected. DirectAccess is Microsoft's transparent always on tunnel. http://technet.microsoft.com/en-us/library/dd759144.aspx

So, it is not anything like a traditional VPN and may not be a good test for your script. But, at the same time is a good test. I did not set it up so I don't pretend to understand how it works. I just know that as soon as I am connected to the internet, I am connected to the work network with DA. It is very slick and is starting to get used more.
All network adapters:

DNSDomain DefaultIPGateway DHCPServer  IPEnabled PhysicalAdapter Manufacturer      Description
--------- ---------------- ----------  --------- --------------- ------------      -----------
                                           False            True Intel Corporation Intel(R) 82579LM Gigabit Network
                                                                                   Connection
                                           False           False Microsoft         Microsoft Kernel Debug Network
                                                                                   Adapter
          {192.168.1.1}    192.168.1.1      True            True Broadcom          Dell Wireless 1504 802.11b/g/n
                                                                                   (2.4GHz)
                                           False           False Microsoft         Microsoft Wi-Fi Direct Virtual
                                                                                   Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False Microsoft         Bluetooth Device (Personal Area
                                                                                   Network)
                                            True           False VMware, Inc.      VMware Virtual Ethernet Adapter for
                                                                                   VMnet1
                                           False           False                   Microsoft Teredo Tunneling Adapter
                                           False           False Microsoft         Microsoft IP-HTTPS Platform Adapter
                                           False           False                   WAN Miniport (SSTP)
                                           False           False                   WAN Miniport (IKEv2)
                                           False           False                   WAN Miniport (PPPOE)
                                           False           False                   WAN Miniport (PPTP)
                                           False           False                   WAN Miniport (L2TP)
                                           False           False                   WAN Miniport (IP)
                                           False           False                   WAN Miniport (IPv6)
                                           False           False                   WAN Miniport (Network Monitor)
                                           False           False                   RAS Async Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False Microsoft         Microsoft ISATAP Adapter
                                            True           False VMware, Inc.      VMware Virtual Ethernet Adapter for
                                                                                   VMnet8
                                           False           False Microsoft         Microsoft ISATAP Adapter
                                           False           False Microsoft         Microsoft ISATAP Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False                   Microsoft ISATAP Adapter
                                           False           False                   Microsoft ISATAP Adapter



Filtered to possible VPN network adapters:

DNSDomain DefaultIPGateway DHCPServer IPEnabled PhysicalAdapter Manufacturer Description
--------- ---------------- ---------- --------- --------------- ------------ -----------
                                          False           False Microsoft    Microsoft Wi-Fi Direct Virtual Adapter
                                          False           False Microsoft    Microsoft IP-HTTPS Platform Adapter
                                          False           False              WAN Miniport (SSTP)
                                          False           False              WAN Miniport (IKEv2)
                                          False           False              WAN Miniport (PPTP)
                                          False           False              WAN Miniport (L2TP)



Filtered to possible VPN network adapters (IP Enabled):

VPN Connection Not Detected

New Post: Test-VPNConnection Function: Need help testing to see if it works reliably in other environments

$
0
0
Thanks for testing again. I did some digging into DirectAccess and it is definitely pretty slick. The best description of it I read was that traditional VPN connects the client to the corporate network. DirectAccess extends the corporate network to the client. I don't have DirectAccess, so if you're willing to work with me and do some testing of my code, I'd like to be able to reliably detect when the user has an active DirectAccess connection to the corporate network.

Based on the research I've done, I'm hoping the below code works to do the detection. If it does not, then the console output should help me modify the code appropriately. Please test and let me know how it goes.
Function Test-DirectAccessCorporateConnectivity
{
    ## Detect if system connected to Microsoft DirectAccess VPN
    [string]$DirectAccessConnectivityReg    = 'HKLM:SOFTWARE\Policies\Microsoft\Windows\NetworkConnectivityStatusIndicator\CorporateConnectivity'
    If (Test-Path -Path $DirectAccessConnectivityReg -ErrorAction 'Stop')
    {
        ## Read connectivity information from registry
        Try
        {
            [psobject]$DirectAccessConnectivity = Get-ItemProperty -Path $DirectAccessConnectivityReg -ErrorAction 'Stop'
        }
        Catch
        {
            Write-Host "Failed to read DirectAccess connectivity information from registry. `n$($_.Exception.Message)"
            Return $false
        }
        
        ## DNS Probing: Resolve Corporate DNS Probe Host Name
        Try
        {
            [string]$DNSProbeHost               = $DirectAccessConnectivity | Select-Object -ExpandProperty 'DnsProbeHost'
            [string]$DNSProbeContent            = $DirectAccessConnectivity | Select-Object -ExpandProperty 'DnsProbeContent'
            Write-Host "DNS Probe Host: $DNSProbeHost"
            Write-Host "DNS Probe Content: $DNSProbeContent"
            
            [string]$DNSProbeHostResolve        = ([System.Net.Dns]::GetHostEntry("$DNSProbeHost"))
            Write-Host "DNS Probe Host Resolution: $DNSProbeHostResolve"
            
            If ($DNSProbeHostResolve -ieq $DNSProbeContent)
            {
                Write-Host "DirectAccess corporate connectivity detected using DNS Probing"
                Return $true
            }
        }
        Catch
        {
            Write-Host "Failed DNS Probing. `n$($_.Exception.Message)"
        }
        
        ## Web Probing: Retrieve Admin Configured Internal Website
        #  The reason for the Web probe is that DirectAccess clients may be located behind a Web proxy server
        #  that performs DNS queries on behalf of the DNS client. Since the DNS client service doesn’t
        #  perform DNS queries for the destination host name for Web proxy clients, this alternate method is required.
        
        Try
        {
            [string]$WebProbeUrl = $DirectAccessConnectivity | Select-Object -ExpandProperty 'WebProbeUrl'
            Write-Host "DNS Web Probe URL: $WebProbeUrl"
            
            If (-not ([string]::IsNullOrEmpty($WebProbeUrl)))
            {
                [System.Net.HttpWebRequest]$request = [System.Net.WebRequest]::Create("$WebProbeUrl")
                $request.Method                     = 'GET'
                $request.Timeout                    = 60000 # = 1 minute
                [System.Net.HttpWebResponse]$result = $request.GetResponse()
                [System.IO.Stream]$stream           = $result.GetResponseStream()
                [System.IO.StreamReader]$reader     = New-Object -TypeName System.IO.StreamReader -ArgumentList $stream
                [string]$output                     = $reader.ReadToEnd()
                
                If (-not ([string]::IsNullOrEmpty($output)))
                {
                    Write-Host "DirectAccess corporate connectivity detected using Web Probing"
                    Return $true
                }
            }
        }
        Catch
        {
            Write-Host "Failed Web Probing. `n$($_.Exception.Message)"
        }
        Finally
        {
            If ($stream)
            {
                $stream.Flush()
                $stream.Close()
            }
        }
    }
    Return $false
}

## Example of using function
If (Test-DirectAccessCorporateConnectivity)
{
    Write-Host 'DirectAccess VPN Connection Detected'     -ForegroundColor 'Green'
}
Else
{
    Write-Host 'DirectAccess VPN Connection Not Detected' -ForegroundColor 'Red'
}

Commented Unassigned: Failed to grab execution mutex [87]

$
0
0
"Failed to grab execution mutex. System error 258." Latest Version Release Notes for 3.2.0: "Added a check for in-progress MSI installations preventing an MSI from installing and waits up to 10 minutes - this reduces instances of MSI error code 1618 (Test-MsiExecMutex)"
by mniccum
Comments: More info would definitely be helpful. Looking at the code however, I do notice one thing but this may not be what the user was trying to communicate. If the code to check for the msi execution mutex fails for some reason, then the Test-MsiExecMutex function should "Return $true" in the Catch block so that the Execute-Process function at least attempts to execute the MSI. And if it fails at that point, then it fails and reports appropriate exit code.

New Post: Test-VPNConnection Function: Need help testing to see if it works reliably in other environments

$
0
0
See the output below. Seems to work. I replaced our domain with "companydomain".
DNS Probe Host: directaccess-corpConnectivityHost.companydomain.local
DNS Probe Content: fd6b:1593:cf5b:7777::7f00:1
Failed DNS Probing.
Exception calling "GetHostEntry" with "1" argument(s): "No such host is known"
DNS Web Probe URL: http://directaccess-WebProbeHost.companydomain.local
DirectAccess corporate connectivity detected using Web Probing
DirectAccess VPN Connection Detected
If I disable my internet connection, I get the following. I will try it when I get in the office today.
DNS Probe Host: directaccess-corpConnectivityHost.companydomain.local
DNS Probe Content: fd6b:1593:cf5b:7777::7f00:1
Failed DNS Probing.
Exception calling "GetHostEntry" with "1" argument(s): "No such host is known"
DNS Web Probe URL: http://directaccess-WebProbeHost.companydomain.local
Failed Web Probing.
Exception calling "GetResponse" with "0" argument(s): "The remote name could not be resolved: 'directaccess-webprobehost
.companydomain.local'"
DirectAccess VPN Connection Not Detected

New Post: Test-VPNConnection Function: Need help testing to see if it works reliably in other environments

$
0
0
In the office, I get the same response that the connection was detected.
DNS Probe Host: directaccess-corpConnectivityHost.companydomain.local
DNS Probe Content: fd6b:1593:cf5b:7777::7f00:1
Failed DNS Probing.
Exception calling "GetHostEntry" with "1" argument(s): "No such host is known"
DNS Web Probe URL: http://directaccess-WebProbeHost.companydomain.local
DirectAccess corporate connectivity detected using Web Probing
DirectAccess VPN Connection Detected

New Post: sccm application policy update

$
0
0
Has anyone tried to use an application policy update during their builds in a script like this to speed up required deployments?


Thanks,

New Post: Stop Process #1 till Process #2 completes

$
0
0
We have a internal add-on/software and during its installation all browser windows has to be closed and no browser has be opened again during installation.

Is it possible to stop browsers from opening/starting during another software installation but after completion this lock should be removed and browsers should be able to start on click?

New Post: Function Execute-Process in 3.2.0 Beta

$
0
0
I'm seeing the same error when actually using test-path:

if(test-path -Path "C:\Program Files\QGIS Dufour\Uninstall-QGIS.exe")
{
#write-host "yay"
Execute-Process -FilePath "C:\Program Files\QGIS Dufour\Uninstall-QGIS.exe" -Arguments "/S" -ContinueOnError $true
this doesn't work with psappdeploytoolkit but works if I move it to an empty script.

New Post: Deployment Script: Oracle Java Runtime 1.7.0.51

$
0
0
"I use WSUS Package Publisher and ServiceUI.exe to update java on 15 000 + clients pretty effortless thanks to your excellent tool!"

I am trying to make use of WSUS PP and PS App DT for JAVA JDK deployments in my work area, but experiencing below problems
  1. WSUS PP is able to push the PADT package to my machine silently and then able to perform the current version of java uninstallation but this is happening in NON INTERACTIVE mode.
  2. After uninstallation, starting installation but with exit code: 1619
  3. Entire process is in non - interactive mode, no windows, no balloon tips nothing.
Kindly suggest what am I missing in here and correct procedure to make PADT to work with WPP.

New Post: Stop Process #1 till Process #2 completes

$
0
0
It most certainly is possible. I have to do the same thing, as most do, when installing Java.

Here is what I did, and made it a std across the board for my systems.

I added the following code to AppDeployToolkitExtensions.ps1 and then call the functions in the script.

*=============================================

Check for java

*=============================================

Function Test-java {
Write-Log "Testing java status..."
Try {
    If (Get-Process "java,javaw" -ErrorAction SilentlyContinue) {
        Write-Log "Java is running."
        Return $true
    }
    Else {
        Write-Log "Java is not running."
        Return $false
    }
}
Catch [Exception] {
    Write-Log "Java is not running."
    Return $false
}
}

*=============================================

Check for IE

*=============================================

Function Test-IE {
Write-Log "Testing Internet Explorer status..."
Try {
    If (Get-Process "iexplore" -ErrorAction SilentlyContinue) {
        Write-Log "Internet Explorer is running."
        Return $true
    }
    Else {
        Write-Log "Internet Explorer is not running."
        Return $false
    }
}
Catch [Exception] {
    Write-Log "Internet Explorer is not running."
    Return $false
}
}

*=============================================

Check for chrome

*=============================================

Function Test-Chrome {
Write-Log "Testing Chrome status..."
Try {
    If (Get-Process "chrome" -ErrorAction SilentlyContinue) {
        Write-Log "Chrome is running."
        Return $true
    }
    Else {
        Write-Log "Chrome is not running."
        Return $false
    }
}
Catch [Exception] {
    Write-Log "Chrome is not running."
    Return $false
}
}

*=============================================

Check for firefox

*=============================================

Function Test-firefox {
Write-Log "Testing Firefox status..."
Try {
    If (Get-Process "firefox" -ErrorAction SilentlyContinue) {
        Write-Log "Firefox is running."
        Return $true
    }
    Else {
        Write-Log "Firefox is not running."
        Return $false
    }
}
Catch [Exception] {
    Write-Log "firefox is not running."
    Return $false
}
}

New Post: Stop Process #1 till Process #2 completes

$
0
0
I also have added a section for checking pending reboots:

*=============================================

Check for pending restart

*=============================================

Function Get-PendingReboot{
<#
.SYNOPSIS
Gets the pending reboot status on a local or remote computer.

.DESCRIPTION

This function will query the registry on a local or remote computer and determine if the
system is pending a reboot, from either Microsoft Patching or a Software Installation.
For Windows 2008+ the function will query the CBS registry key as another factor in determining
pending reboot state. "PendingFileRenameOperations" and "Auto Update\RebootRequired" are observed
as being consistant across Windows Server 2003 & 2008.

CBServicing = Component Based Servicing (Windows 2008)
WindowsUpdate = Windows Update / Auto Update (Windows 2003 / 2008)
CCMClientSDK = SCCM 2012 Clients only (DetermineIfRebootPending method) otherwise $null value
PendFileRename = PendingFileRenameOperations (Windows 2003 / 2008)

.PARAMETER ComputerName
A single Computer or an array of computer names. The default is localhost ($env:COMPUTERNAME).

.PARAMETER ErrorLog
A single path to send error data to a log file.

.EXAMPLE
PS C:> Get-PendingReboot -ComputerName (Get-Content C:\ServerList.txt) | Format-Table -AutoSize

Computer CBServicing WindowsUpdate CCMClientSDK PendFileRename PendFileRenVal RebootPending

DC01 False False False False
DC02 False False False False
FS01 False False False False

This example will capture the contents of C:\ServerList.txt and query the pending reboot
information from the systems contained in the file and display the output in a table. The
null values are by design, since these systems do not have the SCCM 2012 client installed,
nor was the PendingFileRenameOperations value populated.

.EXAMPLE
PS C:> Get-PendingReboot

Computer : WKS01
CBServicing : False
WindowsUpdate : True
CCMClient : False
PendFileRename : False
PendFileRenVal :
RebootPending : True

This example will query the local machine for pending reboot information.

.EXAMPLE
PS C:> $Servers = Get-Content C:\Servers.txt
PS C:> Get-PendingReboot -Computer $Servers | Export-Csv C:\PendingRebootReport.csv -NoTypeInformation

This example will create a report that contains pending reboot information.

.LINK
Component-Based Servicing:
http://technet.microsoft.com/en-us/library/cc756291(v=WS.10).aspx

PendingFileRename/Auto Update:
http://support.microsoft.com/kb/2723674
http://technet.microsoft.com/en-us/library/cc960241.aspx
http://blogs.msdn.com/b/hansr/archive/2006/02/17/patchreboot.aspx

SCCM 2012/CCM_ClientSDK:
http://msdn.microsoft.com/en-us/library/jj902723.aspx

.NOTES
Author: Brian Wilhite
Email: bwilhite1@carolina.rr.com Date: 08/29/2012
PSVer: 2.0/3.0
Updated: 05/30/2013
UpdNote: Added CCMClient property - Used with SCCM 2012 Clients only
Added ValueFromPipelineByPropertyName=$true to the ComputerName Parameter
Removed $Data variable from the PSObject - it is not needed
Bug with the way CCMClientSDK returned null value if it was false
Removed unneeded variables
Added PendFileRenVal - Contents of the PendingFileRenameOperations Reg Entry

>

[CmdletBinding()]
param(
[Parameter(Position=0,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)]
[Alias("CN","Computer")]
[String[]]$ComputerName="$env:COMPUTERNAME",
[String]$ErrorLog
)

Begin{
# Adjusting ErrorActionPreference to stop on all errors, since using [Microsoft.Win32.RegistryKey]
# does not have a native ErrorAction Parameter, this may need to be changed if used within another
# function.
$TempErrAct = $ErrorActionPreference
$ErrorActionPreference = "Stop"
}#End Begin Script Block
Process{
#Foreach ($Computer in $ComputerName){
    Try{
        # Setting pending values to false to cut down on the number of else statements
        $PendFileRename,$Pending,$SCCM = $false,$false,$false

        # Setting CBSRebootPend to null since not all versions of Windows has this value
        $CBSRebootPend = $null

        # Querying WMI for build version
        $WMI_OS = Get-WmiObject -Class Win32_OperatingSystem -Property BuildNumber, CSName -ComputerName $env:COMPUTERNAME

        # Making registry connection to the local/remote computer
        $RegCon = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"LocalMachine",$env:COMPUTERNAME)

        # If Vista/2008 & Above query the CBS Reg Key
        If ($WMI_OS.BuildNumber -ge 6001){
            $RegSubKeysCBS = $RegCon.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\").GetSubKeyNames()
            $CBSRebootPend = $RegSubKeysCBS -contains "RebootPending"
            }#End If ($WMI_OS.BuildNumber -ge 6001)

        # Query WUAU from the registry
        $RegWUAU = $RegCon.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\")
        $RegWUAURebootReq = $RegWUAU.GetSubKeyNames()
        $WUAURebootReq = $RegWUAURebootReq -contains "RebootRequired"

        # Query PendingFileRenameOperations from the registry
        $RegSubKeySM = $RegCon.OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager\")
        $RegValuePFRO = $RegSubKeySM.GetValue("PendingFileRenameOperations",$null)

        # Closing registry connection
        $RegCon.Close()

        # If PendingFileRenameOperations has a value set $RegValuePFRO variable to $true
        If ($RegValuePFRO){$PendFileRename = $true}#End If ($RegValuePFRO)

        # Determine SCCM 2012 Client Reboot Pending Status
        # To avoid nested 'if' statements and unneeded WMI calls to determine if the CCM_ClientUtilities class exist, setting EA = 0
        $CCMClientSDK = $null
        $CCMSplat = @{
            NameSpace='ROOT\ccm\ClientSDK'
            Class='CCM_ClientUtilities'
            Name='DetermineIfRebootPending'
            ComputerName=$env:COMPUTERNAME
            ErrorAction='SilentlyContinue'
            }
        $CCMClientSDK = Invoke-WmiMethod @CCMSplat
        If ($CCMClientSDK){
                If ($CCMClientSDK.ReturnValue -ne 0){Write-Warning "Error: Determine IfRebootPending returned error code $($CCMClientSDK.ReturnValue)"}#End If ($CCMClientSDK -and $CCMClientSDK.ReturnValue -ne 0)
                If ($CCMClientSDK.IsHardRebootPending -or $CCMClientSDK.RebootPending){$SCCM = $true}#End If ($CCMClientSDK.IsHardRebootPending -or $CCMClientSDK.RebootPending)
            }#End If ($CCMClientSDK)
        Else{
            $SCCM = $null
            }                        

        # If any of the variables are true, set $Pending variable to $true
        If ($CBSRebootPend -or $WUAURebootReq -or $SCCM -or $PendFileRename){$Pending = $true}#End If ($CBS -or $WUAU -or $PendFileRename)

        # Creating Custom PSObject and Select-Object Splat
        $SelectSplat = @{
            Property=('Computer','CBServicing','WindowsUpdate','CCMClientSDK','PendFileRename','PendFileRenVal','RebootPending')
            }
        New-Object -TypeName PSObject -Property @{
            Computer=$WMI_OS.CSName
            CBServicing=$CBSRebootPend
            WindowsUpdate=$WUAURebootReq
            CCMClientSDK=$SCCM
            PendFileRename=$PendFileRename
            PendFileRenVal=$RegValuePFRO
            RebootPending=$Pending
            } | Select-Object @SelectSplat
    }#End Try
    Catch{
        Write-Warning "$Computer`: $_"
        # If $ErrorLog, log the file to a user specified location/path
        If ($ErrorLog){Out-File -InputObject "$env:COMPUTERNAME`,$_" -FilePath $ErrorLog -Append}#End If ($ErrorLog)              
    }#End Catch
#}#End Foreach ($Computer in $ComputerName)      
}#End Process

End{
# Resetting ErrorActionPref
$ErrorActionPreference = $TempErrAct
}#End End
}#End Function

New Post: Stop Process #1 till Process #2 completes

$
0
0
we are a notes shop so I also added that in there if you need it. I then comment out the nsd section of there main code as I don't like how it causes notes to exit with a visible error.

Here is the code to check pending reboots:
Get-PendingReboot
If($CBSRebootPend -or $WUAURebootReq -or $SCCM -or $PendFileRename){Show-InstallationRestartPrompt -CountdownSeconds 5405 -CountdownNoHideSeconds 60}


Here is the IE(web browser sections): I have this under the pre-deploy section

$MsgText = "Preparing to install/update $InstallTitle.

"
If((Test-IE -eq $true) -or (Test-Chrome -eq $True) -or (Test-firefox -eq $True) -or (Test-Java -eq $True)){
$MsgText = $MsgText +"Please close your browser(s) and click OK."
$UserPrompt = Show-InstallationPrompt -message $MsgText -ButtonLeftText "Cancel" -ButtonRightText "OK" -Icon "Information" -MinimizeWindows $True -Timeout 900
If($UserPrompt -eq "Cancel"){Exit-Script -ExitCode "5000"}
ElseIf($UserPrompt -eq "OK"){Show-InstallationWelcome -AllowDeferCloseApps "chrome,firefox,iexplore,java" -BlockExecution -DeferTimes $PostponeTimes}
}
Else{
$UserPrompt = Show-InstallationPrompt -message "$MsgText" -ButtonLeftText "Cancel" -ButtonRightText "OK" -Icon "Information" -MinimizeWindows $True -ExitTimeout 900
If($UserPrompt -eq "Cancel"){Exit-Script -ExitCode "5000"}
ElseIf($UserPrompt -eq "OK"){Show-InstallationWelcome -CloseApps "chrome,firefox,iexplore,java" -silent -BlockExecution}
ElseIf(!($UserPrompt)){Show-InstallationWelcome -CloseApps "chrome,firefox,iexplore,java" -silent -BlockExecution}
}

Hope this helps :)

New Post: Function Execute-Process in 3.2.0 Beta

$
0
0
Does the error go away if you use the updated code I posted right about your post?

Created Unassigned: Remove-MSIApplications executing for empty objects [89]

$
0
0
When I execute Remove-MSIApplications and nothing is returned it still attempts to initiate a removal one time. I believe changing the following line of code within the Remove-MSIApplications function will resolve...

current:
If ($installedApplications -ne "") {

new:
If ($installedApplications -ne $isnull) {

New Post: Get-MSIProperty

$
0
0
Hello all,
This extension retrieves the value of any Property stored in the Property Table of a target MSI file.
Function Get-MSIProperty {
<#
.SYNOPSIS
    Retrieves the value of a property defined in target MSI file Property Table
.DESCRIPTION
    Specify the full path to the MSI and the property name that stores the value to retrieve. Function will return the value if property is found in the MSI.
.EXAMPLE
    Get-MSIProperty "C:\windows\installer\abc123.msi" "ProductCode"
    Returns the ProductCode value from abc123.msi file.
.EXAMPLE
    $MyProductCode = Get-MSIProperty "C:\windows\installer\abc123.msi" "ProductCode"
    Returns the ProductCode value from abc123.msi file and then stores it in $MyProductCode variable.
.PARAMETER MSIFileName
    The full path to the target MSI file.
.PARAMETER MSIPropertyName
    The name of the property to retrieve.
.NOTES
.LINK
    Http://psappdeploytoolkit.codeplex.com
#>
    Param(
        [Parameter(Mandatory = $true)]
        [string] $MSIFileName,
        [string] $MSIPropertyName
    )
    
    $WindowsInstaller = New-Object -com WindowsInstaller.Installer
    $Database = $WindowsInstaller.GetType().InvokeMember(“OpenDatabase”, “InvokeMethod”, $Null, $WindowsInstaller, @($MSIFileName,0))
    $View = $Database.GetType().InvokeMember(“OpenView”, “InvokeMethod”, $Null, $Database, (“SELECT * FROM Property”))
    $View.GetType().InvokeMember(“Execute”, “InvokeMethod”, $Null, $View, $Null)

    $Record = $View.GetType().InvokeMember(“Fetch”, “InvokeMethod”, $Null, $View, $Null)

    while($Record -ne $Null)
    {
        $PropertyName = $Record.GetType().InvokeMember(“StringData”, “GetProperty”, $Null, $Record, 1)
        if ($PropertyName -eq $MSIPropertyName)
        {
            $PropertyValue = $Record.GetType().InvokeMember(“StringData”, “GetProperty”, $Null, $Record, 2)
            $PropertyValue
        }
        $Record = $View.GetType().InvokeMember(“Fetch”, “InvokeMethod”, $Null, $View, $Null)
    }
}

New Post: Get-MSIProperty

$
0
0
You should pipe this line to Out-Null:
$View.GetType().InvokeMember(“Execute”, “InvokeMethod”, $Null, $View, $Null)

Like so:
$View.GetType().InvokeMember(“Execute”, “InvokeMethod”, $Null, $View, $Null) | Out-Null

The reason being that executing that method sends a null value into the pipeline. When you read a property value from the MSI table, the $null value in the pipeline gets added to the property value you read from the MSI table and you now have an array where the first element is $null. Because of the way PowerShell treats arrays, especially when the first element is $null, you will get a string with a space at the front if you treat this array as as string. You can test this by reading the ProductCode from an MSI and then checking to see if there is a mysterious space at the front of the ProductCode or not.

Also, you should close the view to the MSI once you're done.
$View.GetType().InvokeMember(“Close”, “InvokeMethod”, $Null, $View, $Null) | Out-Null
Viewing all 2341 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>