Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 1.02 KB

31-Using-NET-in-Powershell-Part-5.md

File metadata and controls

34 lines (24 loc) · 1.02 KB

31. Using .NET in Powershell Part 5

Add-Type
$ApiCode = @"

[DllImport("kernel32.dll")]
public static extern bool CreateSymbolicLink(string lpSymlinkFileName, string lpTargetFileName, int dwFlags);

"@

$SymLink = Add-Type -MemberDefinition $ApiCode -Name Symlink  -Namespace CreatSymLink -PassThru
$SymLink::CreateSymbolicLink('C:\test\link', 'C:\Users\', 1)
PS C:\Users\Administrator\Desktop> .\New-SymLink.ps1
True
PS C:\Users\Administrator\Desktop>

Image of API