Year 2012 will be over soon. At the time of this blog being published, I am on my way to China for my vacation. In the middle of 2012, my contact job was changed. My previous contact job is mainly as software developer to support historian services for SCADA system. Development work only took small portion of my time, I was mainly responsible to provide support for applications, such as SQL server, Parcview, and applications I wrote.
When my contract was terminated, I thought I would never to touch Parcview. I was looking for .Net development jobs, as well as iOS development. In my personal profile and resume, I did not mention Parcview at all. To my surprise, I got a call from a company, in about 2 weeks of my break, to ask me to fill a role to provide support for Parcview. As a result, I accepted the offer. Now my IT role has been changed since. Not much development work, my work, or new contract, has been mainly on Parcview and historian service support. In 2012, a big change happened in my career.
Even though I know Parcview and historian services very well, there are still many new challenges. I think this provides me a good opportunity to extend my skills and knowledge in this area. Since my work is mainly in support case, I have not touched codes at all. I tried to reorganize some of previous Visual Studio projects and trie to find a way to put them in my work. So far, my effort has not been approved yet.
My iOS app has been on hold as well. The career change may be one of reasons I delayed my app. Another reason is that I have been waiting for my daughter to provide art work for my app. The app is about 80% finished. All my iOS development are in my afterwork hours.
I had a talk with my best friend over a weekend. He asked me what are my new goals for the year 2013. Among many goals I would like to complemented, to continue my iOS development is one of them. My current contract has been extended for the year 2013. I am pretty much sure there will be not much development at my support work. Therefore, I will focus on iOS or even Mac OS app development. I have to make my effort to plan my time and allocate enough resources to continue my software development. I hope this will extend my software development to a more existing area.
Monday, December 31, 2012
Year 2012 is Over, Welcome Year 2013
Posted by D Chu at 2:13 PM 0 comments
Labels: iOS Development
Tuesday, December 18, 2012
Get Folder Permissions by Scripts (3)
In terms of getting folder permissions by using PS script, the first two blogs are just good enough. As a bonus and my personal reference, here are simple helper function and entry point. That completes my blog about my script.
The help function is a very simple one which prints out the usage of the script. The same practice can be applied to other scripts.
# FUNCTION LISTINGS
# =============================================================================
# Function: HelpInfo
# Created: [11/25/2009]
# Author: David Chu
# Arguments:
# $p_scriptApp: script application
# -------------------------------------------
# Purpose: display usage message
# -------------------------------------------
function HelpInfo($p_scriptApp)
{
Write-Output ""
Write-Output "Description: Get permissions for a folder."
Write-Output "Parameters: folderPath [outFile] [/s]"
Write-Output "Where"
Write-Output " folderPath: a path for a folder"
Write-Output " outFile: output file"
Write-Output " /s: recursive to get sub folders"
Write-Output "Examples:"
Write-Output "This one running from PowerShell:"
Write-Output (" PS: {0} C:\MyData" -f $p_scriptApp)
Write-Output "The following example running from cmd console:"
Write-Output (" cmd> PowerShell {0} C:\MyData myFile /s" -f $p_scriptApp)
}
PS entry section is the place to get all the parameters from command line.
# Example to run this script:
# @powershell d:\Scripts\GetPerm.ps1 'D:\Displays\Public' /s
# Result:
D:\Displays\Users Everyone:(OI)(CI)F
BUILTIN\Administrators:(OI)(CI)F
NT AUTHORITY\SYSTEM:(OI)(CI)F
CREATOR OWNER:(OI)(CI)(IO)F
BUILTIN\Users:(OI)(CI)R
BUILTIN\Users:(CI)(special access:)
FILE_APPEND_DATA
BUILTIN\Users:(CI)(special access:)
FILE_WRITE_DATA
#*=============================================================================
#* SCRIPT BODY
#*=============================================================================
# example parameter values for this script. Add the parameter to PowerGUI Script
# Editor's Input toolbar:
# C:\Users /s
$scriptApp = "GetPerm.ps1"
# check input arguments
if ( $args.length -eq 0 -or $args.length -gt 3 )
{
HelpInfo $scriptApp
return
}
# Get the first input parameter
$i = 0
$folderPath = $args[$i++
$outFile = "outFile.txt"]
$recursive = $false
if ($args.length -gt 1)
{
if ( $args[$i++].ToLower() -eq "/s")
{
$recursive = $true
if ($args.length -gt 2)
{
$outFile = $args[$i++]
}
}
else
{
$outFile = $args[$i++]
if ($args[$i++] -eq "/s")
{
$recursive = $true
}
}
}
# check if source and dest pathes exist
if ( Test-Path -Path $folderPath | where {!$_PSIsContainer} )
{
GetFolderPermission $folderPath $recursive $outFile
} else {
Write-Output ("Invalid path: {0}" -f $folderPath)
}
#*=============================================================================
#* END OF SCRIPT BODY
#*=============================================================================
In PS, command line argument can be obtained from $args[] collection, and the number of arguments is the property of length of $args. Each argument can be enclosed by single quote ' char, not double " char.
Posted by D Chu at 1:30 PM 0 comments
Labels: PowerShell, Windows Tools
Tuesday, December 11, 2012
Get Folder Permissions by Scripts (2)
I created a simple function in PowerShell script to get folder permissions. As I mentioned in my previous blog, a DOS command is used to get folder permissions: Calcs. If there is subfolder within a folder, the function provides recursive option to get subfolder permissions. In addition to that, the folder can contain wild characters such as "*data".
To get all the containers as a collection in PS, the command is Get-Item with option $_.PSIsContainer:
$fs = Get-Item -Path $p_Path | Where-Object {$_.PSIsContainer }
The following is the function
# Function: GetFolderPermission
# Created: [10/02/2012]
# Author: David Chu
# Arguments:
# $p_Path: folder
# $p_recursive: true for recursive, false for not
# -------------------------------------------
# Purpose: get folder permissions
# -------------------------------------------
function GetFolderPermission(
$p_Path,
$p_outFile,
$p_recursive)
{
# get all the files matched and timestamp > comparing date
$fs = Get-Item -Path $p_Path | Where-Object {$_.PSIsContainer }
if ( $fs -ne $null )
{
foreach ($folder in $fs)
{
$fullDir = $folder.FullName
Write-Output $fullDir
$cmd = 'cacls "{0}"' -f $fullDir
Invoke-Expression $cmd | out-File -Append $p_outFile
if ( $p_recursive )
{
$fsSub = Get-ChildItem -Path $fullDir |Where-Object {$_.PSIsContainer}
if ( $fsSub -ne $null)
{
foreach ($subDir in $fsSub)
{
$fullDir = $subDir.FullName
GetFolderPermission $fullDir $p_recursive $p_outFile
}
}
}
}
}
}
The above codes are very straightforward, therefore, no need to explain.
Posted by D Chu at 3:35 PM 0 comments
Labels: PowerShell, Windows Tools
Tuesday, December 04, 2012
Get Folder Permissions by Scripts (1)
I found there is a DOS command tool to get folder permissions: Calcs. By using this tool, permissions can be added, deleted or modified as well. Based on this findings, I used PowserShell to create a script to get folder permissions. I am planning to further to enhance this script to create duplicated permissions for a specified folder.
Here is a example of using the script in a batch script:
C:\test\powershell c:\scripts\GetPerm.ps1'C:\MyData' /s
The result is something like this:
D:\MyData Everyone:(OI)(CI)F
BUILTIN\Administrators:(OI)(CI)F
NT AUTHORITY\SYSTEM:(OI)(CI)F
CREATOR OWNER:(OI)(CI)(IO)F
BUILTIN\Users:(OI)(CI)R
BUILTIN\Users:(CI)(special access:)
FILE_APPEND_DATA
BUILTIN\Users:(CI)(special access:)
FILE_WRITE_DATA
If there are sub-folders within, the script will loop through to get all sub-fodler permissions as well.
It is possible to use WMI class or other tools in PS to get folder permissions. Calcs is a free tool in Windows. I found it is much easy to leverage its power to do the job.
Posted by D Chu at 10:13 AM 0 comments
Labels: PowerShell