Quantcast
Channel: AutoSPInstaller
Viewing all articles
Browse latest Browse all 2279

Commented Issue: Win32_Products to be avoided ! [22135]

$
0
0
the Get-SharePointInstall function takes a long time to process because it is using the wim (or cim) win32_products class. According to mister google this class should be avoided.
Explanation here:
https://sdmsoftware.com/group-policy-blog/wmi/why-win32_product-is-bad-news/

_When you query this class, the way the provider works is that it actually performs a Windows Installer “reconfiguration” on every MSI package on the system as its performing the query_

and here:

http://gregramsey.net/2012/02/20/win32_product-is-evil/
_even though you called a basic query of the Win32_Product class, you actually performed a consistency check of each installation._

in my case I replaced this line
if (Get-CimInstance -ClassName Win32_Product -Filter "Name like 'Microsoft SharePoint Server%'")

with this:

if(Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* ) | where-Object {$_.DisplayName -like "Microsoft SharePoint Server*"}
Comments: ** Comment from web user: SpRambler **

there is an error in the last note ( if ([string]::IsNullOrEmpty($Installed)))

here is a simpler version

after modifying the Get-SharePointInstall as follows:

```
Function Get-SharePointInstall()
{
Write-Host 'Checking Sharepoint Install'
$IsInstalled = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | where-Object {$_.DisplayName -like 'Microsoft SharePoint Server*'}
if([string]::IsNullOrEmpty($IsInstalled))
{
return $false
}
else {
return $true
}
Write-Host 'End Checking Sharepoint Install'
}
```

you call it like this:
```
$spInstalledOnRemote = Invoke-Command -ScriptBlock ${function:Get-SharePointInstall} -Session $session


```


Viewing all articles
Browse latest Browse all 2279

Trending Articles