Skip to content

Instantly share code, notes, and snippets.

View Dan1el42's full-sized avatar

Daniel Krebs Dan1el42

View GitHub Profile
Import-Csv -Path '.\Input.csv' |
Select-Object -Property MACHINENAME, @{Name='OSVERSION'; Expression={ Get-WmiObject -Class Win32_OperatingSystem -Property Caption -ComputerName $_.MACHINENAME -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Caption }} |
Export-Csv -Path '.\Output.csv' -NoTypeInformation
Set-ItemProperty -Path $defaultFTP -Name ftpServer.security.ssl.serverCertHash -Value 582EF84C1D431738C0A5F75C845CAA03D81E63B6 # Replace my sample thumbprint with the value from your certificate
# Data channel ports are a per server configuration not per site
Set-WebConfigurationProperty -PSPath IIS:\ -Filter system.ftpServer/firewallSupport -Name lowDataChannelPort -Value 5001
Set-WebConfigurationProperty -PSPath IIS:\ -Filter system.ftpServer/firewallSupport -Name highDataChannelPort -Value 5001
Param
(
[Parameter(Mandatory)]
[System.String]
$Path,
[System.String]
$Filter = '*.jpg',
[System.String]
$Targetfolder ="C:\temp\logs"
$Extension = "*.log"
$logfile = New-Item -Path 'C:\TEMP' -ItemType "file" -Name deleted.log
$files = Get-ChildItem $Targetfolder -Include $Extension -Recurse | where {$_.LastWriteTime -lt (get-date).Adddays(-180)}
foreach ($File in $Files)
{
if ($File -ne $Null)
{
write-host "Deleting File $File" -BackgroundColor DarkGreen
@Dan1el42
Dan1el42 / TestBug.psm1
Last active August 27, 2015 15:29
Bug in PowerShell v5 version of 2016 TP3
# Get-DscResource -Module TestBug | Select-Object -ExpandProperty Properties
# Un-comment the ValidateNotNullEmpty attribute to repro the bug
enum Ensure
{
Present
Absent
}
[DscResource()]
@Dan1el42
Dan1el42 / Unlock-WebSiteConfigurationSection.ps1
Created August 2, 2015 14:26
Unlock web site configuration section
$Splat = @{
Filter = '/system.webServer/security/authentication/windowsAuthentication'
Metadata = 'overrideMode'
Value = 'Allow'
PSPath = IIS:\
Location = 'Default Web Site'
}
Set-WebConfiguration @Splat
@Dan1el42
Dan1el42 / DscActiveDirectoryDomainController.ps1
Created May 20, 2015 07:56
PowerShell DSC - Active Directory Domain Controller script
Configuration DCSERVER {
Param (
[Parameter(Mandatory)]
[PSCredential]
$DomainAdministratorCredential,
[Parameter(Mandatory)]
[PSCredential]
@Dan1el42
Dan1el42 / git-default-setup.ps1
Last active August 29, 2015 14:19
Git Default Setup
git config --global push.default simple
git config --global pull.rebase true
git config --global rerere.enabled true
git config --global color.ui true
git config --global alias.s "status -s"
git config --global alias.lg "log --oneline --decorate --all --graph"
Param
(
[Parameter(Mandatory = $true)]
[String] $ComputerName
)
# S-1-5-32-544 is the well-known security ID for the Administrators group
$LocalGroup = Get-WmiObject -Class Win32_Group -Filter "SID = 'S-1-5-32-544'" -ComputerName $ComputerName
if ($LocalGroup)
{
@Dan1el42
Dan1el42 / HashTable-PowerShell.ps1
Last active August 29, 2015 14:08
PowerShell versions
@{
'6.1.7600' = '2.0'
'6.2.9200.16434' = '3.0'
'6.3.9600.17090' = '4.0'
'6.3.9701.0' = '5.0 Preview April'
'6.3.9740.0' = '5.0 Preview May'
'6.4.9789.0' = '5.0 Preview July'
'6.4.9814.0' = '5.0 Preview September'
'6.4.9841.0' = '5.0 Windows 10 TP'
}