Skip to content

Instantly share code, notes, and snippets.

View Stephanevg's full-sized avatar
:octocat:
I like computers

Van Gulick Stephanevg

:octocat:
I like computers
View GitHub Profile
@Stephanevg
Stephanevg / Set-SCCMDetectionRuleForDeploymentType.ps1
Last active July 20, 2020 19:32
This function will help to create custom detection deployment types for SCCM 2012
Function Set-SCCMDetectionRuleForDeploymentType {
Param(
[Parameter(Mandatory=$True)]
[ValidateSet("RegistryKey","File","Folder","MSI","Assembly","Other")]
$DetectionType,
[Parameter(Mandatory=$False,ParameterSetName="FileDetection")][ValidateNotNullOrEmpty()][String]$FileName,
[Parameter(Mandatory=$False,ParameterSetName="FileDetection")][ValidateNotNullOrEmpty()][String]$FolderPath,
[Parameter(Mandatory=$False,ParameterSetName="FileDetection")]$Is64bit,
@Stephanevg
Stephanevg / New-SCCMDetectionRuleForDeploymentType.ps1
Last active July 20, 2020 19:32
The New-SCCMDetectionRuleForDeploymentType helps to creates a new detection method for a deploymentType on an existing Application
Function New-SCCMDetectionRuleForDeploymentType {
Param(
[Parameter(Mandatory=$True)]
[ValidateSet("RegistryKey","File","Folder","MSI","Assembly","Other")]
$DetectionType,
[Parameter(Mandatory=$False,ParameterSetName="FileDetection")][ValidateNotNullOrEmpty()][String]$FileName,
[Parameter(Mandatory=$False,ParameterSetName="FileDetection")][ValidateNotNullOrEmpty()][String]$FolderPath,
[Parameter(Mandatory=$False,ParameterSetName="FileDetection")]$Is64bit,
@Stephanevg
Stephanevg / Load-ConfigMgrAssemblies.ps1
Created June 21, 2016 18:48
Function to load the needed SCCM dll's that are needed to automate Application and enhanced detection rules with powershell. Call the function at the start of your sccript.
Function Load-ConfigMgrAssemblies {
Param(
$AdminConsoleDirectory = "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin"
)
#Add-Type -Path "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\DcmObjectModel.dll"
$filesToLoad = "Microsoft.ConfigurationManagement.ApplicationManagement.dll","AdminUI.WqlQueryEngine.dll", "AdminUI.DcmObjectWrapper.dll","DcmObjectModel.dll","AdminUI.AppManFoundation.dll","AdminUI.WqlQueryEngine.dll","Microsoft.ConfigurationManagement.ApplicationManagement.Extender.dll","Microsoft.ConfigurationManagement.ManagementProvider.dll","Microsoft.ConfigurationManagement.ApplicationManagement.MsiInstaller.dll"
Set-Location $AdminConsoleDirectory
[System.IO.Directory]::SetCurrentDirectory($AdminConsoleDirectory)
foreach($fileName in $filesToLoad)
{
@Stephanevg
Stephanevg / createRandomFiles.ps1
Last active October 3, 2022 17:30
This function will create random files. It allows you to select the total size all the files together must have, and the number of individual files to create in total. (for example, A total of 5GB in 100 different files). The main advantage of this function is that it will create files with human understandeble names (and if your lucky, funny na…
Function Create-RandomFiles{
<#
.SYNOPSIS
Generates a number of dumb files for a specific size.
.DESCRIPTION
Generates a defined number of files until reaching a maximum size.
.PARAMETER Totalsize
Specify the total size you would all the files combined should use on the harddrive.
@Stephanevg
Stephanevg / Get-CMSurfaceNetworkAdapter
Created July 18, 2016 13:08
Manage-SurfaceNetworkAdapter
Function Get-CMSurfaceNetworkAdapter {
Param(
[string]$Add,
[string]$Remove,
[switch]$ListSurfaceAdapters
)
#Based on following technet article: https://blogs.technet.microsoft.com/system_center_configuration_manager_operating_system_deployment_support_blog/2015/08/27/reusing-the-same-nic-for-multiple-pxe-initiated-deployments-in-system-center-configuration-manger-osd/
$Root = 'HKLM:\SOFTWARE\Microsoft\SMS\Components\SMS_DISCOVERY_DATA_MANAGER'
$Item = 'ExcludeMACAddress'
@Stephanevg
Stephanevg / print-webpageToPdf.ps1
Last active September 8, 2016 14:04
Print a webpage with powershell. More information here -> http://powershelldistrict.com/print-webpage-pdf-powershell/
Function Print-WebPageToPDF{
<#
.SYNOPSIS
Prints a specefic webPage to PDF.
.DESCRIPTION
If no fileName is given, it will print the file name with the current date & time
.EXAMPLE
Will print a file called powershelldistrict.pdf to the path C:\temp\print
@Stephanevg
Stephanevg / Get-joke.ps1
Created August 19, 2016 11:46
get-Joke
Function Get-Joke
{
((iwr -uri "http://tambal.azurewebsites.net/joke/random").content |Convertfrom-Json).joke
}
Get-Joke
@Stephanevg
Stephanevg / Get-MacOsXsysteminformation.ps1
Last active May 2, 2021 19:51
get system information on a mac os x system using powershell
function Get-MacOsXsysteminformation {
[xml]$infos = system_profiler -xml
return $infos
}
Class Computer {
[String]$Name
[String]$Type
[string]$Description
[string]$owner
[string]$Model
[int]$Reboots
[void]Reboot(){
$this.Reboots ++
@Stephanevg
Stephanevg / enum_servertype.ps1
Last active September 1, 2016 16:11
enum servertype used in powershell classes: a practical example part 2 ---> http://powershelldistrict.com/a-practical-case-for-using-powershell-classes-part2
Enum ServerType {
HyperV
Sharepoint
Exchange
Web
ConfigMgr
}