Skip to content

Instantly share code, notes, and snippets.

View anuriq's full-sized avatar

Azat Khadiev anuriq

  • Ozon
  • Moscow, Russia
View GitHub Profile
@anuriq
anuriq / windowsfeatures.xml
Created November 6, 2015 08:45
windows features template for Install-WindowsFeature cmdlet
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<Obj RefId="0">
<TN RefId="0">
<T>System.Collections.ObjectModel.Collection`1[[System.Management.Automation.PSObject, System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]</T>
<T>System.Object</T>
</TN>
<LST>
<Obj RefId="1">
<TN RefId="1">
<T>Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/ServerComponent_Application_Server</T>
@anuriq
anuriq / bootstrapurl.ps1
Last active November 19, 2015 10:05
bootstrap AWS images
function Get-PendingReboot {
<#
.SYNOPSIS
Gets the pending reboot status on a local or remote computer.
.DESCRIPTION
This function will query the registry on a local or remote computer and determine if the
system is pending a reboot, from either Microsoft Patching or a Software Installation.
For Windows 2008+ the function will query the CBS registry key as another factor in determining
pending reboot state. "PendingFileRenameOperations" and "Auto Update\RebootRequired" are observed
@anuriq
anuriq / WinRM_File_Copy.cs
Created November 9, 2015 16:01
code example to copy files through winrm
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Security;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Security;
@anuriq
anuriq / windowsfeatures2.xml
Created February 2, 2016 10:57
this time with FTP
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<Obj RefId="0">
<TN RefId="0">
<T>System.Collections.ObjectModel.Collection`1[[System.Management.Automation.PSObject, System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]</T>
<T>System.Object</T>
</TN>
<LST>
<Obj RefId="1">
<TN RefId="1">
<T>Microsoft.Management.Infrastructure.CimInstance#ROOT/Microsoft/Windows/ServerManager/ServerComponent_NET_Framework_45_ASPNET</T>
function Get-PendingReboot {
<#
.SYNOPSIS
Gets the pending reboot status on a local or remote computer.
.DESCRIPTION
This function will query the registry on a local or remote computer and determine if the
system is pending a reboot, from either Microsoft Patching or a Software Installation.
For Windows 2008+ the function will query the CBS registry key as another factor in determining
pending reboot state. "PendingFileRenameOperations" and "Auto Update\RebootRequired" are observed

Keybase proof

I hereby claim:

  • I am anuriq on github.
  • I am anuriq (https://keybase.io/anuriq) on keybase.
  • I have a public key whose fingerprint is 5DAC B7D0 809B 196A 2F5E E93E EB31 FF47 EFE0 C68B

To claim this, I am signing this object:

$ knife bootstrap windows ssh -x Administrator -P <mypassword> --secret-file ~/.chef/data_bag_secret --policy-group production --policy-name <mypolicy> -N <myfqdn> <myfqdn> -VV
INFO: Using configuration from /Users/akhadiev/.chef/knife.rb
DEBUG: Looking for key chef_node_name and found value <myfqdn>
DEBUG: Chef::HTTP calling Chef::HTTP::JSONInput#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::JSONOutput#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::CookieManager#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Decompressor#handle_request
DEBUG: Chef::HTTP calling Chef::HTTP::Authenticator#handle_request
DEBUG: Signing the request as akhadiev
codes_file = open('C:\\Users\\udmin\\Documents\\sources.txt')
codes_list = codes_file.readlines()
codes_list2 = []
for c in codes_list: codes_list2.append(c.split(','))
target_file = open('C:\\Users\\udmin\\Documents\\list.txt')
target_list = [x.strip() for x in target_file.readlines()]
from __future__ import print_function
from datetime import datetime
from random import randint
from time import sleep
import psycopg2
def main():
try: