Skip to content

Instantly share code, notes, and snippets.

View cyberautomate's full-sized avatar

cyberautomate

View GitHub Profile
Configuration LCMPullConfig
{
LocalConfigurationManager
{
ConfigurationID = "EXCH";
RefreshMode = "PULL";
DownloadManagerName = "WebDownloadManager";
RebootNodeIfNeeded = $true;
RefreshFrequencyMins = 30;
ConfigurationModeFrequencyMins = 30;
# Your Configuration
Configuration ExchangeService {
# Parameters
# Accepts a string value computername or defaults to localhost
Param([string[]]$ComputerName = "localhost")
# Target Node
Node $ComputerName {
# Service Resource
# Step 1 Install xPSDesiredStateConfiguration
Install-Module -Name xPSDesiredStateConfiguration
# Step 2
# Create the Pull Server.
Configuration CreatePullServer {
param (
[string[]]$ComputerName = 'localhost'
)
# Get all the DSC CMDLets
Get-Command -Noun dsc*
# Get Available Resources
# Refer to powershellgallery.com for additional resources
Get-DscResource
# What can we configure for each resource
Get-DscResource File | Select -ExpandProperty Properties
# Your Configuration
Configuration ExchangeService {
# Parameters
# Accepts a string value computername or defaults to localhost
Param([string[]]$ComputerName = "localhost")
# Target Node
Node $ComputerName {
<#
DESCRIPTION
This script will search a file structure for a specific file type and export the results to a CSV file.
This can be used to search a user accessible file share for file types that you may have policies
against storing on a file share. If you don’t have access to Enterprise tools like FSRM this is an
easy way to provide similar functionality.
#>
#This is what Directory you want to search
$searchDir = "c:\files"
<#
DESCRIPTION
Use WMI to gather hardware and software information remotely from domain clients.
The script pings a list of computernames and runs the inventory on livePCs.txt.
Once all the hardware/software information is collected, all the data is exported
to a CSV file.
PARAMETER
No parameters, just change the execution policy and run the script
#>
<#
DESCRIPTION
Use WMI to gather hardware and software information remotely from domain clients.
The script pings a list of computernames and runs the inventory on livePCs.txt.
Once all the hardware/software information is collected, all the data is exported
to a CSV file.
PARAMETER
ComputerName(s), see the examples below.
<#
DESCRIPTION
Searches all OUs in Active Directory, or a subset of OUs and looks for the
ProtectedFromAccidentalDeletion property is set to $false.
The code at the bottom of the script will find the OUs and set them to
Protectedfromaccidental $true
#>
<#
DESCRIPTION
Retrieve the username of the user that logged into a computer last.
#>
# Option 1
$computer = 'dc1'
Get-ChildItem "\\$computer\c$\Users" | Sort-Object LastWriteTime -Descending | Select-Object Name, LastWriteTime -first 1
# Option 2