PowerShell Module

PowerShell Module

Define PowerShell module:

# comm_func.psm1

$ORA_CONNECTION = $null

Function FileExist {
    param ([String] $path)
    If($path -eq $null) {
        Return $False
    } Else {
        Return (Test-Path -Path "$path" -PathType leaf)
    }
}

Function FolderExist {
    param ([String] $path)
    If(($path -eq $null) -Or ($path -eq '')) {
        Return $False
    } Else {
        Return (Test-Path -Path "$path")
    }
}

# export module
Export-ModuleMember -Function "*Exist"
Export-ModuleMember -Variable "ORA_CONNECTION"

Put it in use:

Import-Module comm_func.psm1

if (-not (FolderExist "$a_dir")) {
    mkdir "$a_dir"
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章