Created
March 24, 2017 18:37
-
-
Save adamdriscoll/039b5303210956794abfaaebd090159c to your computer and use it in GitHub Desktop.
Create profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CreateProfile | |
{ | |
param([String]$pszUserSid, [String]$pszUserName, [System.Text.StringBuilder]$pszProfilePath, [uint]$cchProfilePath) | |
Add-Type -TypeDefinition ' | |
using System; | |
using System.Runtime.InteropServices; | |
public static class PInvoke { | |
[DllImport("userenv.dll", SetLastError = true, CharSet = CharSet.Auto)] | |
public static extern int CreateProfile( [MarshalAs(UnmanagedType.LPWStr)] String pszUserSid, [MarshalAs(UnmanagedType.LPWStr)] String pszUserName, [Out, MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszProfilePath, uint cchProfilePath); | |
} | |
' | |
[PInvoke]::CreateProfile($pszUserSid, $pszUserName, $pszProfilePath, $cchProfilePath) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment