Terry L@u's blog: Move the IIS default path on Windows Server 2008 o...: For security reason, administrators might be needed to move the default IIS path, Inetpub, to non-system drive. According to KB2752331 ,...
The only thing is I don't think running the xcopy command at the end is useful as it is contained in the microsoft script line 23.
MAXNOP8
SQL Server, SSIS, powershell
Friday, January 8, 2016
Tuesday, December 8, 2015
Wednesday, November 4, 2015
Wednesday, October 14, 2015
ORA-00439: feature not enabled: Deferred Segment Creation on datapump import
Life and Oracle: ORA-00439: feature not enabled: Deferred Segment C...: Short version: If you get this error on a data pump import: ORA-39083: Object type TABLE:"SCOTT"."EMP" failed to creat...
Monday, August 11, 2014
Find User SID using Powershell
These snippets allow to find a local or AD user SID or get the username from the SID
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
<# | |
.SYNOPSIS | |
Finds SID for a local user account. | |
.DESCRIPTION | |
Returns the SID of a local user account. To find the SID for an active directory user use | |
findADSID instead | |
.PARAMETER $user | |
The user for which to find the SID | |
.EXAMPLE | |
PS C:\> findLocalSID -user Guest | |
.INPUTS | |
System.String | |
.OUTPUTS | |
System.String | |
.LINK | |
about_functions_advanced | |
.LINK | |
about_comment_based_help | |
#> | |
function findLocalSID($user) { | |
$Objuser = New-Object System.Security.Principal.NTAccount($user) | |
$strSID = $Objuser.Translate([System.Security.Principal.SecurityIdentifier]) | |
return $strSID.Value | |
} | |
<# | |
.SYNOPSIS | |
finds the SID for an Active directory user | |
.DESCRIPTION | |
returns a string in the form of an sid | |
.PARAMETER $domain | |
the domain the user belongs to | |
.PARAMETER $user | |
the domain user | |
.EXAMPLE | |
PS C:\> findADSID -domain <domain> -user <user> | |
.INPUTS | |
System.String | |
.OUTPUTS | |
System.String | |
.LINK | |
about_functions_advanced | |
.LINK | |
about_comment_based_help | |
#> | |
function findADSID{ | |
param( | |
[Parameter(Mandatory = $true)] | |
$domain, | |
[Parameter(Mandatory = $true)] | |
$user) | |
$Objuser = New-Object System.Security.Principal.NTAccount($domain,$user) | |
$strSID = $Objuser.Translate([System.Security.Principal.SecurityIdentifier]) | |
return $strSID.Value | |
} | |
<# | |
.SYNOPSIS | |
find User id based on SID Value | |
.DESCRIPTION | |
returns user name | |
.PARAMETER $sid | |
sid value (not quoted) | |
.EXAMPLE | |
PS C:\> findUserFromSID S-1-5-21-2213100911-2073097868-631715938-506 | |
.INPUTS | |
System.String | |
.OUTPUTS | |
System.String | |
.NOTES | |
Additional information about the function goes here. | |
.LINK | |
about_functions_advanced | |
.LINK | |
about_comment_based_help | |
#> | |
function findUserFromSID{ | |
param( | |
[Parameter(Mandatory = $true)] | |
$sid | |
) | |
$objSID = New-Object System.Security.Principal.SecurityIdentifier($sid) | |
$Objuser = $objSID.Translate([system.Security.Principal.NTAccount]) | |
return $Objuser.Value | |
} |
Rename all files in directory using powershell part 2
Using Powershell 4 :
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
#Rename all files in a directory , setting all characters to lowercase and excluding directories | |
gci -Path D:\temp\ -File -Filter "txt*" | foreach{$_| Rename-Item -NewName $_.Name.ToLower()} -ErrorAction SilentlyContinue | |
#Rename all files in a directory , change only the first letter to lowercase | |
gci -Path D:\temp\ -File -Filter "*.txt" | foreach{$_| ` | |
Rename-Item -NewName $($_.Name.substring(0,1).Tolower() + $_.Name.Substring(1))} -ErrorAction SilentlyContinue | |
#rename only x first file in directory , changing the first letter to lower case, if the source equals the destination we get an error message | |
gci -Path D:\temp\ -File -Filter "*.txt" | Select-Object -First 9 | foreach{$_| ` | |
Rename-Item -NewName $($_.Name.substring(0,1).Tolower() + $_.Name.Substring(1))} -ErrorAction SilentlyContinue | |
#test if first letter is uppercase or lowercase to avoid errors | |
gci -Path D:\temp\ -File - Filter "*.txt"| Select-Object -First 10| foreach{$_| Rename-Item -NewName $(if($_.name.substring(0,1) -cmatch "[a-z]") {$_.Name.substring(0,1).ToUpper() + $_.Name.Substring(1)} | |
elseif ($_.Name.substring(0,1) -cmatch "[A-Z]") {$_.Name.substring(0,1).ToLower() + $_.Name.Substring(1)}) | |
} -ErrorAction SilentlyContinue |
Subscribe to:
Posts (Atom)