Skip to content

Instantly share code, notes, and snippets.

View lazywinadmin's full-sized avatar

François-Xavier Cat lazywinadmin

View GitHub Profile
@lazywinadmin
lazywinadmin / gist:5869055
Created June 26, 2013 16:39
Get-SCCMComputer
if($computerName) {
return Get-WMIObject -ComputerName $siteProvider -Namespace "root\sms\site_$siteCode" -class "SMS_R_System" -filter "Name LIKE `"%$ComputerName%`""
} elseif($resourceId) {
return Get-WMIObject -ComputerName $siteProvider -Namespace "root\sms\site_$siteCode" -Class "SMS_R_System" -filter "ResourceID=$resourceId"
} else {
return Get-WMIObject -ComputerName $siteProvider -Namespace "root\sms\site_$siteCode" -Class "SMS_R_System"
@lazywinadmin
lazywinadmin / Get-WmiObject_NoFiltering.ps1
Last active December 19, 2015 00:49
Get-WmiObject Without Filter
# In the module we have the following query
# (I had Backtick to fit in my blog, don't do this at home! ;-) )
$computer = Get-WMIObject `
-ComputerName $siteProvider `
-Namespace "root\sms\site_$siteCode" `
-Class "SMS_R_System" | Where { $_.ResourceID -eq $resourceId }
# Let's measure our command on a big environment (+6000 computers)
# Note that I replaced some values, you need to specify the SiteProvider, SiteCode and
# ResourceID.
@lazywinadmin
lazywinadmin / Get-WmiObject_Filtering.ps1
Last active December 19, 2015 00:49
Get-WmiObject with Filtering
# Let's measure our command on a big environment (+6000 computers) with some filtering
# Note that I replaced some values, you need to specify the SiteProvider, SiteCode and
# ResourceID.
Measure-Command {Get-WMIObject`
-ComputerName <SiteProvider> `
-Namespace "root\sms\site_<SITECODE>" `
-Query "Select * From SMS_R_System WHERE ResourceID='<ResourceID>'"}
Days : 0
Hours : 0
#requires -Version 3.0
#requires -PSSnapin VMware.VimAutomation.Core
function Enable-VMCopyPaste
{
[CmdletBinding()]
PARAM(
[string[]]$vm
)
BEGIN{
#requires -Version 3.0
#requires -PSSnapin VMware.VimAutomation.Core
function Disable-VMCopyPaste
{
[CmdletBinding()]
PARAM(
[string[]]$vm
)
BEGIN{
#http://www.lazywinadmin.com/2013/10/powershell-get-domainuser.html
function Get-DomainUser {
PARAM($DisplayName)
$Search = [adsisearcher]"(&(objectCategory=person)(objectClass=User)(displayname=$DisplayName))"
foreach ($user in $($Search.FindAll())){
New-Object -TypeName PSObject -Property @{
"DisplayName" = $user.properties.displayname -as [string]
"UserName" = $user.properties.samaccountname -as [string]
"Description" = $user.properties.description -as [string]
#http://www.lazywinadmin.com/2013/10/powershell-get-domainuser.html
function Get-DomainUser {
PARAM($DisplayName)
$Search = [adsisearcher]"(&(objectCategory=person)(objectClass=User)(displayname=$DisplayName))"
foreach ($user in $($Search.FindAll())){
New-Object -TypeName PSObject -Property @{
"DisplayName" = $user.properties.displayname -as [string]
"UserName" = $user.properties.samaccountname -as [string]
"Description" = $user.properties.description -as [string]
@lazywinadmin
lazywinadmin / getdomainuser_phonenumber3.ps1
Created May 17, 2014 16:54
getdomainuser_phonenumber3.ps1
function Get-DomainUser
{
PARAM ($DisplayName,[Adsi]$SearchRoot= "LDAP://OU=Servers,OU=TEST,dc=fx,dc=lab")
$Search = [adsisearcher]"(&(objectCategory=person)(objectClass=User)(displayname=$DisplayName))"
$Search.searchRoot = $SearchRoot
foreach ($user in $($Search.FindAll()))
{
New-Object -TypeName PSObject -Property @{
"DisplayName" = $user.properties.displayname -as [string]
"UserName" = $user.properties.samaccountname -as [string]
@lazywinadmin
lazywinadmin / Get-NestedMember.ps1
Created October 22, 2014 02:43
Get-NestedMember
function Get-NestedMember
{
<#
.SYNOPSIS
Find all Nested members of a group
.DESCRIPTION
Find all Nested members of a group
.PARAMETER GroupName
Specify one or more GroupName to audit
.Example
@lazywinadmin
lazywinadmin / textbox_paste_clipboard.ps1
Created October 25, 2014 02:24
textbox_paste_clipboard.ps1
#------------------------------------------------------------------------
# Source File Information (DO NOT MODIFY)
# Source ID: 7cc35deb-97f1-4821-9fac-1339de8a644c
# Source File: C:\Users\Francois-Xavier\SkyDrive\Scripts\PowerShell\GitHub\PowerShellGUI\_Examples_Winforms\ClipBoard_Paste.psf
#------------------------------------------------------------------------
<#
.NOTES
--------------------------------------------------------------------------------
Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2014 v4.1.71