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
%Office% SQL
Get the details of all files and folders using power-shell
Change the path variable for your requests-
$path = "C:\temp\" Get-ChildItem -Path $path |Select-Object *|Export-Csv -Path "C:\temp\Folder_details.csv" -Force
if you want just the path and name of the files/folders –
$path = "C:\temp\" Get-ChildItem |Select-Object name,fullname |Export-Csv -Path "C:\temp\Folder_details.csv" -Force
%Microsoft Visio Professional%
Select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceId = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName = "%Microsoft Visio Professional%"
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
Turn off Bluetooth if no Device is connected actively
Get the Exe file from the following website - https://www.nirsoft.net/utils/bluetooth_viewer.html create the following power shell script
$LogFile = "C:\Windows\MSSCCM\Logs\Toggle_Bluetooth_OFF.log" Function LogWrite { Param ([string]$logstring) $logcontent = "$date $logstring" Add-Content $Logfile -Value $logcontent } New-Item -ItemType Directory -Path "C:\Windows\MSSCCM\Scripts\Bluetooth" -Force -ErrorAction SilentlyContinue $date=Get-Date -Format g $PREDirectory = Split-Path -Parent $MyInvocation.MyCommand.Definition $InstDir = Split-Path -parent $MyInvocation.MyCommand.Definition LogWrite "START $date*********************************************" $Parameters = '/sxml "C:\Windows\MSSCCM\Scripts\bluetooth\bluetooth.xml"' $Commandtorun = "btView.exe" $process= Start-Process $CommandToRun $Parameters -PassThru -wait -workingdirectory $InstDir $ExtVal = $process.ExitCode logwrite "created the XML file with code:$ExtVal" if(Test-Path "C:\Windows\MSSCCM\Scripts\bluetooth\bluetooth.xml") { logwrite "Searching for any connected devices" $IS_device_connected = Select-String -Path "C:\Windows\MSSCCM\Scripts\bluetooth\bluetooth.xml" -Pattern "<connected>Yes</connected>" -SimpleMatch -Quiet if(!$IS_device_connected) { logwrite "NO Devices are connected, so toggling the bluetooth setting OFF" ################################################################ #*********TURN OFF BLUETOOTH AS NO DEVICE IS CONNECTED*********# ################################################################ Function Bluetooth { [CmdletBinding()] Param ( [Parameter(Mandatory=$true)][ValidateSet('Off', 'On')][string]$BluetoothStatus ) If ((Get-Service bthserv).Status -eq 'Stopped') { Start-Service bthserv } Add-Type -AssemblyName System.Runtime.WindowsRuntime $asTaskGeneric = ([System.WindowsRuntimeSystemExtensions].GetMethods() | ? { $_.Name -eq 'AsTask' -and $_.GetParameters().Count -eq 1 -and $_.GetParameters()[0].ParameterType.Name -eq 'IAsyncOperation`1' })[0] Function Await($WinRtTask, $ResultType) { $asTask = $asTaskGeneric.MakeGenericMethod($ResultType) $netTask = $asTask.Invoke($null, @($WinRtTask)) $netTask.Wait(-1) | Out-Null $netTask.Result } [Windows.Devices.Radios.Radio,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null [Windows.Devices.Radios.RadioAccessStatus,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null Await ([Windows.Devices.Radios.Radio]::RequestAccessAsync()) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null $radios = Await ([Windows.Devices.Radios.Radio]::GetRadiosAsync()) ([System.Collections.Generic.IReadOnlyList[Windows.Devices.Radios.Radio]]) $bluetooth = $radios | ? { $_.Kind -eq 'Bluetooth' } [Windows.Devices.Radios.RadioState,Windows.System.Devices,ContentType=WindowsRuntime] | Out-Null Await ($bluetooth.SetStateAsync($BluetoothStatus)) ([Windows.Devices.Radios.RadioAccessStatus]) | Out-Null } Bluetooth -Verbose -BluetoothStatus Off LogWrite "Turned OFF the bluetooth on the machine" #################################################################### #################################################################### } else { LogWrite "Exiting the Script as there are Bluetooth devices connected to the machine " } } else { LogWrite "There was an error running the tool to create the XML file" } LogWrite "END $date******************************************************" LogWrite ""
Query SCCM Cache Size
wmic /namespace:\\ROOT\CCM\SoftMgmtAgent path CacheConfig get
Powershell Script for All ADUsers
PROCESS #This is where the script executes { $path = "C:\temp\" $pathexist = Test-Path -Path $path If ($pathexist -eq $false) {New-Item -type directory -Path $path} $reportdate = Get-Date -Format ssddmmyyyy $csvreportfile = $path + "\ALLADUsers_$reportdate.csv" #import the ActiveDirectory Module Import-Module ActiveDirectory #Perform AD search. The quotes "" used in $SearchLoc is essential #Without it, Export-ADUsers returuned error Get-ADUser -Properties * -Filter * | Select-Object @{Label = "First Name";Expression = {$_.GivenName}}, @{Label = "Last Name";Expression = {$_.Surname}}, @{Label = "Display Name";Expression = {$_.DisplayName}}, @{Label = "Logon Name";Expression = {$_.sAMAccountName}}, @{Label = "Full address";Expression = {$_.StreetAddress}}, @{Label = "City";Expression = {$_.City}}, @{Label = "State";Expression = {$_.st}}, @{Label = "Post Code";Expression = {$_.PostalCode}}, @{Label = "Country/Region";Expression = {if (($_.Country -eq 'GB') ) {'United Kingdom'} Else {''}}}, @{Label = "Job Title";Expression = {$_.Title}}, @{Label = "Company";Expression = {$_.Company}}, @{Label = "Description";Expression = {$_.Description}}, @{Label = "Department";Expression = {$_.Department}}, @{Label = "Office";Expression = {$_.OfficeName}}, @{Label = "Phone";Expression = {$_.telephoneNumber}}, @{Label = "Email";Expression = {$_.Mail}}, @{Label = "Manager";Expression = {%{(Get-AdUser $_.Manager -Properties DisplayName).DisplayName}}}, @{Label = "Account Status";Expression = {if (($_.Enabled -eq 'TRUE') ) {'Enabled'} Else {'Disabled'}}}, # the 'if statement# replaces $_.Enabled @{Label = "Last LogOn Date";Expression = {$_.lastlogondate}} | #Export CSV report Export-Csv -Path $csvreportfile -NoTypeInformation }
SCCM.bat
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." }
event viewer log export by event id
Set-Variable -Name EventAgeDays -Value 1 #we will take events for the latest 7 days Set-Variable -Name CompArr -Value @("$env:COMPUTERNAME") # replace it with your server names Set-Variable -Name LogNames -Value @("Application", "System") # Checking app and system logs Set-Variable -Name ExportFolder -Value "c:\EWLogsbyEventID\" # change this yo your own location $el_c = @() #consolidated error log $now=get-date if($ExportFolder){New-Item -Path $ExportFolder -ItemType Directory -Force} $startdate=$now.adddays(-$EventAgeDays) $ExportFile=$ExportFolder + "el" + $now.ToString("yyyy-MM-dd---hh-mm-ss") + ".csv" # we cannot use standard delimiteds like ":" foreach($comp in $CompArr) { foreach($log in $LogNames) { Write-Host Processing $comp\$log $el = get-eventlog -ComputerName $comp -LogName $log -After $startdate | where EventID -EQ 1000 $el_c += $el #consolidating } } $el_sorted = $el_c | Sort-Object TimeGenerated #sort by time Write-Host Exporting to $ExportFile $el_sorted|Select EntryType, TimeGenerated, Source, EventID, MachineName, Message | Export-CSV $ExportFile -NoTypeInfo #EXPORT
OS Installed Date > 10 Days
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_OPERATING_SYSTEM on SMS_G_System_OPERATING_SYSTEM.ResourceId = SMS_R_System.ResourceId WHERE dateDiff(dd, SMS_G_System_OPERATING_SYSTEM.InstallDate, GetDate()) > 10
PNP Drivers import using Powershell
Get Add remove program entries from local or remote machines using Powershell in a CSV format
Get Add remove program entries from local or remote machines using Powershell in a CSV format-
function Get-Uninstall { param([parameter(Mandatory = $true)]$computer) # paths: x86 and x64 registry keys are different Start-Process "C:\windows\system32\sc.exe" -ArgumentList "\\$computer start winrm" Invoke-Command -ComputerName $computer -ScriptBlock { if ([IntPtr]::Size -eq 4) { $path = 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' } else { $path = @( 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*' 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*' ) } # get all data Get-ItemProperty $path | # use only with name and unistall information .{process{ if ($_.DisplayName -and $_.UninstallString) { $_ } }} | # select more or less common subset of properties Select-Object DisplayName, Publisher, InstallDate, DisplayVersion, HelpLink, UninstallString | # and finally sort by name Sort-Object DisplayName } Start-Process "C:\windows\system32\sc.exe" -ArgumentList "\\$computer stop winrm" } Get-Uninstall | Export-Csv -LiteralPath "$env:HOMEDRIVE\temp\ARP_Details.csv"-Force -NoTypeInformation
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{}
#######################
Intune Device Enrollment
md c:\\HWID Set-Location c:\\HWID Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted Install-Script -Name Get-WindowsAutoPilotInfo Get-WindowsAutoPilotInfo.ps1 -OutputFile AutoPilotHWID.csv
https://docs.microsoft.com/en-us/windows/deployment/windows-autopilot/add-devices
The post Intune Device Enrollment appeared first on SCCM Cuurent Branch Blog.
Intune Configuration Backup
https://github.com/ThomasKur/IntuneDocumentation
The post Intune Configuration Backup appeared first on SCCM Cuurent Branch Blog.
Add
The post Add appeared first on SCCM Cuurent Branch Blog.