Wednesday, November 25, 2015

powershell compress single file via NTFS (pinvoke)

Add-Type @"
using System;
using System.IO;
using System.Runtime.InteropServices;
public class NTFSFileCompression
{
#pragma warning disable
[DllImport("kernel32.dll")]
public static extern bool DeviceIoControl(
IntPtr hDevice, uint dwIoControlCode, ref short lpInBuffer, uint nInBufferSize,
IntPtr lpOutBuffer, uint nOutBufferSize, ref uint lpBytesReturned,
IntPtr lpOverlapped);
private const uint FSCTL_SET_COMPRESSION = 0x0009C040;
private const short COMPRESSION_FORMAT_NONE = 0;
private const short COMPRESSION_FORMAT_DEFAULT = 1;
private static bool SetCompression(IntPtr handle, short compression)
{
uint lpBytesReturned = 0;
return DeviceIoControl(
handle, FSCTL_SET_COMPRESSION, ref compression, 2, IntPtr.Zero,
0, ref lpBytesReturned, IntPtr.Zero);
}
public static bool SetFileCompressed(string path)
{
using (FileStream fs = OpenFileStream(path))
{
return SetCompression(fs.Handle, COMPRESSION_FORMAT_DEFAULT);
}
}
public static bool SetFileUncompressed(string path)
{
using (FileStream fs = OpenFileStream(path))
{
return SetCompression(fs.Handle, COMPRESSION_FORMAT_NONE);
}
}
private static FileStream OpenFileStream(string path)
{
return File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
}
}
"@
[NTFSFileCompression]::SetFileCompressed([string]"aFile.txt")
C# Source: http://www.blackwasp.co.uk/FileCompression.aspx

Monday, July 27, 2015

Azure Powershell

1. Azure Powershell installieren https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/ 2. Azure subscription installieren http://blogs.technet.com/b/canitpro/archive/2013/11/06/set-by-step-manage-windows-azure-using-powershell.aspx 3. Powershell Session zur Azure-VM aufbauen https://gallery.technet.microsoft.com/scriptcenter/Configures-Secure-Remote-b137f2fe

ssh - allow password authentication to localhost

Match address 127.0.0.1/32,::1
PasswordAuthentication yes

Sunday, July 19, 2015

xrdp session resumption

X11RDP/ xrdp has no proper session resumption / reconnection
X11RDP-o-Matic fixes this /etc/xrdp/xrdp.ini [globals] address=127.0.0.1

apt install history

/var/log/apt/history.log

Monday, March 30, 2015

nop.exe

#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
void main() {
;
}
view raw gistfile1.cpp hosted with ❤ by GitHub
nop.exe
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat
Cl nop.c

add windows user to sql instance in single user mode

"D:\Microsoft SQL Server\<INSTANCE_NAME>\MSSQL\Binn\sqlservr.exe" -s<INSTANCE_NAME> -m
wichtig parameter für sqlcmd sind case sensitive
sqlcmd -E -S<SERVERNAME>\<INSTANCE_NAME>
CREATE LOGIN [<domain>\<user>] FROM WINDOWS;
GO
SP_ADDSRVROLEMEMBER '<domain>\<user>', 'sysadmin'
GO

Sunday, January 4, 2015

embed gist snippets in blogspot

How to embed gist snippets in blogspot

create QR Code for Google Authenticator without using google charts API

One time pad authentication for apache: mod-authn-otp/
create QR Code for Google Authenticator without using google charts API (source code gpl): qr generator
Google Authenticator

apt-get install php5 php5-gd libapache2-mod-php5