:::: MENU ::::
Browsing posts in: Uncategorized


MY PS

$RESGUIDPATH = ‘HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{6C3683DE-A9F3-4BFA-BDF4-337860D52039}’

If((Test-Path $RESGUIDPATH) -eq $true){

$RESGUIDINFO = (Get-ItemProperty -Path $RESGUIDPATH)

If(($RESGUIDINFO.DisplayName -eq ‘RES ONE Workspace 2016 SR1 Agent’ `
-and $RESGUIDINFO.DisplayVersion -eq ‘9.12.1.0’) -or `
($RESGUIDINFO.DisplayName -eq ‘RES ONE Workspace 2016 SR1 Agent’ `
-and $RESGUIDINFO.DisplayVersion -eq ‘9.12.1.2’))

{Write-Host ‘Installed’}

Else {}

}

Else{}

#######################



Powershell Script for Installed driver details to export



param(
    [string]$outputFile
)

$dateTimeString = $(get-date -UFormat '%Y-%m-%d_%T.%S').Replace(':','')
if (! ($outputFile)) {
    $outputFile = "c:\temp\$($env:computername)--PnpSignedDrivers--$($dateTimeString).csv"
}

#$netBackupShare = '\\SHARE\PnPSignedDrivers'

$deviceIdIgnoreList= @(
    'Send To OneNote 2013',
    'WebEx Document Loader',
    'HTREE\ROOT\0',
    'Fax',
    'Microsoft Print to PDF',
    'Microsoft XPS Document Writer'
);

$selectObjectList = @(
    'DeviceClass',
    'Manufacturer',
    'DriverVersion',
#'DriverDate',
    @{Label='DriverDate';Expression={$_.ConvertToDateTime($_.DriverDate)}},
    'Description',
    'DeviceName',
    'FriendlyName',
    'CompatID',
    'DeviceID',
    'HardWareID',
    'DevLoader',
    'DriverName',
    'DriverProviderName',
    'InfName',
    'InstallDate',
    'IsSigned',
    'Signer'
);

Write-Host ''
Write-Host 'Pulling PnP Signed Drivers from WMI ...'
$wmiClass = 'Win32_PnPSignedDriver'
$drivers = Get-WmiObject $wmiClass | 
    Where-Object { !($deviceIdIgnoreList.Contains($_.DeviceID)) } |
    Select-Object $selectObjectList |
        Sort-Object Manufacturer,DeviceClass,Description

if ($drivers) {
    Write-Host ''
    Write-Host 'Exporting results to .CSV ...'
        $drivers | Export-Csv -Path $outputFile

    Write-Host '--> Cleaning up .CSV ...'
    $fileBuffer = Get-Content -Path $outputFile | Select -Skip 1
    Set-Content -Path $outputFile -Value $fileBuffer

    Write-Host ''
    Write-Host "Final output file is located at:`r`n   `"$($outputFile)`""

   # Copy-Item $outputFile "$($netBackupShare)\"
#    Write-Host ''
   # Write-Host "File has also been backed up to:`r`n   $($netBackupShare)\"
} else {
    Write-Host ''
    Write-Host "No driver '$($wmiClass)' was found."
}



CCM repair

#Stop and remove ccm service
& sc stop ccmsetup
& sc delete ccmsetup

#Remove ccm certs
Remove-Item ‘HKLM:\SOFTWARE\Microsoft\SystemCertificates\SMS\Certificates\*’ -Force

#Remove ccm files
Remove-Item -Path $env:windir\ccm -Recurse -Force
Remove-Item -Path $env:windir\system32\ccm -Recurse -Force
Remove-Item -Path $env:windir\ccmcache -Recurse -Force
Remove-Item -Path $env:windir\ccmsetup -Recurse -Force
Remove-Item -Path $env:windir\system32\ccmsetup -Recurse -Force
Remove-Item -Path $env:windir\smscfg.ini -Force
Remove-Item -Path $env:windir\sms*.mif -Force

#Remove ccm registry keys
$RegRoot = “HKLM:\Software\Microsoft”
Remove-Item -Path “$RegRoot\ccm” -Recurse -Force
Remove-Item -Path “$RegRoot\ccmsetup” -Recurse -Force
Remove-Item -Path “$RegRoot\sms” -Recurse -Force

#Remove ccm wmi namespaces
Get-WmiObject -Query “SELECT * FROM __Namespace WHERE Name=’CCM'” -Namespace “root” | Remove-WmiObject
Get-WmiObject -Query “SELECT * FROM __Namespace WHERE Name=’SMS'” -Namespace “root\cimv2” | Remove-WmiObject

#Repair WMI
$Path = ‘C:\Windows\System32\wbem’
Stop-Service -Name Winmgmt -Force
Remove-Item “$Path\repository” -Recurse -Force
& wmiprvse /regserver
Start-Service -Name Winmgmt
Get-ChildItem $Path -Filter *.dll | ForEach-Object { & regsvr32.exe /s $_.FullName } | Out-Null
Get-ChildItem $Path -Filter *.mof | ForEach-Object { & mofcomp.exe $_.FullName } | Out-Null
Get-ChildItem $Path -Filter *.mfl | ForEach-Object { & mofcomp.exe $_.FullName } | Out-Null
& mofcomp.exe ‘C:\Program Files\Microsoft Policy Platform\ExtendedStatus.mof’ | Out-Null


%Office% SQL


SELECT DISTINCT  
  SYS.Name0
  ,ARP.DisplayName0 As 'Software Name'
  ,ARP.Version0 As 'Version'
  ,ARP.InstallDate0 As 'Installed Date'
 FROM 
  dbo.v_R_System As SYS
  INNER JOIN dbo.v_FullCollectionMembership FCM On FCM.ResourceID = SYS.ResourceID 
  INNER JOIN dbo.v_Add_REMOVE_PROGRAMS As ARP On SYS.ResourceID = ARP.ResourceID 
 WHERE   
 (ARP.DisplayName0 LIKE '%Microsoft % Standard%'
 OR ARP.DisplayName0 LIKE 'Microsoft % Professional%'
 OR ARP.DisplayName0 LIKE 'Microsoft % Enterprise %')
 ORDER BY Name0 ASC


Using Machine – OutPut :-User Name,AD site code,AD discoverd date,Active Client,Client Status,Obsolete Client,HW SCAN DIFFERENCE

SELECT Name0 AS [Machine Name], User_Name0 AS [User Name],AD_site_name0 as [AD site code] ,creation_date0 as [AD discoverd date],
CASE Active0 WHEN ‘0’ THEN ‘InActive’ WHEN ‘1’ THEN ‘Active’ ELSE ‘Unknown’ END AS [Active Client],

CASE Client0 WHEN ‘0’ THEN ‘No’ WHEN ‘1’ THEN ‘Yes’ ELSE ‘Unknown’ END AS [Client Status],

CASE obsolete0 WHEN ‘0’ THEN ‘No’ WHEN ‘1’ THEN ‘Yes’ ELSE ‘Unknown’ END AS [Obsolete Client], DATEDIFF(D,V_GS_WORKSTATION_STATUS.LASTHWSCAN,GETDATE()) AS [HW SCAN DIFFERENCE]

FROM v_R_System LEFT JOIN V_GS_WORKSTATION_STATUS ON V_R_SYSTEM.RESOURCEID = V_GS_WORKSTATION_STATUS.RESOURCEID

WHERE (Name0 IN (‘XXXXX’,’SSS’))


SQL LeftJoin Template

Select Name, [Disk_Space] from

(Select * From V_FullcollectionMembership where CollectionID = ‘ XXXX’ ) AllMachines

LeftJoin
( XXXXXXX  ) DiskSpace

On AllMachines.Name=Diskspace.[Computer Name]

____________________________________________________________
Example :—
______

select Name, [DISK_SPACE]
from
(select *
from v_FullCollectionMembership
where collectionID = ‘XXX00BB5’) allMachines
left join
(SELECT DISTINCT
v_R_System.Netbios_Name0 AS [Computer Name], v_R_System.User_Name0 as [ User name],
DisplayName AS [Baseline Item],
v_StateNames.StateName AS [Baseline Status],

case v_StateNames.StateName when ‘Compliant’ then ‘Yes’ when ‘Non-Compliant’ then ‘No’ when ‘Unknown’ then ‘Unknown’ when ‘Error’ then ‘Error’ ELSE v_StateNames.StateName END AS [DISK_SPACE]

FROM   dbo.v_CICurrentComplianceStatus INNER JOIN
dbo.v_CIAssignmentToCI ON v_CICurrentComplianceStatus.CI_ID = v_CIAssignmentToCI.CI_ID INNER JOIN
dbo.v_CIAssignment ON v_CIAssignmentToCI.AssignmentID = v_CIAssignment.AssignmentID INNER JOIN
dbo.v_LocalizedCIProperties ON v_CICurrentComplianceStatus.CI_ID = v_LocalizedCIProperties.CI_ID INNER JOIN
dbo.v_StateNames ON v_CICurrentComplianceStatus.ComplianceState = v_StateNames.StateID INNER JOIN
dbo.v_R_System ON v_CICurrentComplianceStatus.ResourceID = v_R_System.ResourceID INNER JOIN
dbo.v_FullCollectionMembership ON dbo.v_R_System.ResourceID = dbo.v_FullCollectionMembership.ResourceID
WHERE (v_StateNames.TopicType = 401) AND (v_CIAssignment.CollectionID = ‘XXX00B86’)
AND (dbo.v_FullCollectionMembership.CollectionID = ‘XXX00B86’)
and ( dbo.v_LocalizedCIProperties.DisplayName = ‘Machines With Low Disk Space (Less Than 10GB)’)
) DiskSpace
on allMachines.Name = DiskSpace.[Computer Name]


Pages:123