Skip to content

Instantly share code, notes, and snippets.

Option Explicit
On Error Resume Next
Dim objshell, strPSPath, strPSArg, strScriptFolder
Set objShell = WScript.CreateObject("WScript.Shell")
strPSPath = objShell.ExpandEnvironmentStrings("%SystemRoot%") & "\System32\WindowsPowerShell\v1.0\Powershell.exe"
strScriptFolder = Left(WScript.ScriptFullName, (Len(WScript.ScriptFullName) - (Len(WScript.ScriptName))))
strPSArg = "-ExecutionPolic ByPass -NonInteractive -NoProfile -File " & Chr(34) & strScriptFolder & "Run-LogonScript.ps1" & Chr(34)
objShell.Run Chr(34) & strPSPAth & Chr(34) & Chr(32) & strPSArg, 0, True
$Principal = New-ScheduledTaskPrincipal -GroupId 'BUILTIN\Users'
$Command = Join-Path $env:SystemRoot -ChildPath 'System32\WScript.exe'
$Argument = '//NoLogo //B //T:120 "C:\Windows\LogonScript.vbs"'
$TaskAction = New-ScheduledTaskAction -Execute $Command -Argument $Argument
$TaskSetting = New-ScheduledTaskSettingsSet -Compatibility 'Win8' -ExecutionTimeLimit '00:05' -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -DontStopOnIdleEnd
$TaskTrigger = @((New-ScheduledTaskTrigger -AtLogOn), (New-ScheduledTaskTrigger -At '7am' -Daily))
$TaskTrigger | Where-Object { $_.StartBoundry } | ForEach-Object { $_.StartBoundry = [DateTime]::Parse($_.StartBoundry).ToLocalTime().ToString('s') }
$Task = New-ScheduledTask -Action $TaskAction -Trigger $TaskTrigger -Settings $TaskSetting -Principal $Principal
$Task.Description = 'Scheduled task to run logon script at user logon and every day at 7am'
Register-ScheduledTask -InputObject $Task -TaskPath '\' -TaskName 'LogonScript'
<#
// Data class to be inventoried by SCCM hardware inventory on the client
[SMS_Report(TRUE),SMS_Group_Name("Certificates"),SMS_Class_ID("Custom Inventory|Certificates|1.0")]
Class Certificates: SMS_Class_Template
{
[ SMS_Report (FALSE), Key ] String Thumbprint;
[ SMS_Report (FALSE) ] String Subject;
[ SMS_Report (FALSE) ] String NotBefore;
[ SMS_Report (FALSE) ] String NotAfter;
[ SMS_Report (FALSE) ] String SignatureAlgorithm;
$FilePath = 'C:\Temp\report_01.csv'
$OutputPath = 'C:\Temp\report_02.csv'
$Key = Split-Path -Path $FilePath -Leaf
$Url = 'https://s3.aws.com'
$BucketName = 'us-east-low-rw-team-a-shared'
$ProfileName = 'low_teams_shared'
Set-AWSCredential -AccessKey 'AWS_ACCESS_KEY' -SecretKey 'AWS_PASSWORD' -StoreAs $ProfileName
Set-AWSCredential -ProfileName $ProfileName
Write-S3Object -EndpointUrl $Url -BucketName $BucketName -Key $Key -File $FilePath
Import-Module -Name 'ConfigurationManager'
$SiteCode = 'LCL'
$Location = Get-Location
Set-Location $SiteCode":\" -ErrorAction 'Stop'
$Collection = Get-CMDeviceCollection -Name 'HR_Servers'
if ($Collection)
{
$Rule = $Collection | Get-CMDeviceCollectionQueryMembershipRule | Where-Object { $_.RuleName -eq 'HR server manaul query' }
if ($Rule){ Remove-CMDeviceCollectionQueryMembershipRule -CollectionId $Collection.CollectionID -RuleName $Rule.RuleName -Force }
$TrustName = "ClaimsXray"
$AuthZRules = "=>issue(Type = `"http://schemas.microsoft.com/authorization/claims/permit`", Value = `"true`"); "
$IssuanceRules = "@RuleName = `"Issue all claims`"`nx:[]=>issue(claim = x); "
$RedirectUrl = "https://adfshelp.microsoft.com/ClaimsXray/TokenResponse"
$SamlEndpoint = New-AdfsSamlEndpoint -Binding 'POST' -Protocol 'SAMLAssertionConsumer' -Uri $RedirectUrl
Add-ADFSRelyingPartyTrust `
-Name $TrustName `
-Identifier "urn:microsoft:adfs:claimsxray" `
-IssuanceAuthorizationRules $AuthzRules `
-IssuanceTransformRules $IssuanceRules `
$Inf = @"
[NewRequest]
Subject="CN=adfs.infra.private,O=Local,OU=IT,C=US"
KeySpec = 1
KeyLength = 2048
HashAlgorithm = SHA256
Exportable = TRUE
MachineKeySet = TRUE
SMIME = False
PrivateKeyArchive = FALSE
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)][String] $ComputerName = $env:COMPUTERNAME,
[Parameter(Mandatory=$false)][ValidateSet('Start','Stop','Enable','Delete','Create')][String] $Action
)
try
{
$TaskName = 'Maintenace'
$TaskPath = '\'
$Servers = Import-Csv -Path 'D:\Data\ListOfServers.csv'
$Output = @('Source','Destination','IPAddress','PingStatus','Date','Time','ErrorMessage')
$Servers = $Servers | Select-Object -Property @{Name='HostName';Expression={$_.ComputerName}},@{Name='Data';Expression={ [String]::Empty | Select-Object -Property $Output}}
$Servers | fl *
$Servers | ForEach-Object -Parallel {
$_.Data.Date = (Get-Date -Format 'dd-MMM-yyyy')
$_.Data.Time = (Get-Date -Format 'HH:mm:ss')
$_.Data.Source = $env:COMPUTERNAME
pragma solidity ^0.5.15;
contract IERC20_v1 {
function totalSupply() public view returns (uint256);
function balanceOf(address _account) public view returns (uint256);
function transfer(address _to, uint256 _tokens) public returns (bool);
function approve(address _spender, uint256 _tokens) public returns (bool);
function transferFrom(address _from, address _to, uint256 _tokens) public returns (bool);
function allowance(address _account, address _spender) public view returns (uint256);