Tuesday, May 23, 2017
Automating Flat File Imports
https://www.mssqltips.com/sqlservertip/3208/automating-flat-file-sql-server-imports-with-powershell/
Thursday, May 4, 2017
Using Calculated Properties
https://technet.microsoft.com/en-us/library/ff730948.aspx
Works well with Select-Object
$reportsFolder='c:\temp'
Get-ChildItem -Path $reportsFolder | `
Select-Object DirectoryName,Name,@{Name="LastWriteDate"; Expression={$_.LastWriteTime.ToString("d")}}
Works well with Select-Object
$reportsFolder='c:\temp'
Get-ChildItem -Path $reportsFolder | `
Select-Object DirectoryName,Name,@{Name="LastWriteDate"; Expression={$_.LastWriteTime.ToString("d")}}
Formatting Dates and Times
https://technet.microsoft.com/en-us/library/ee692801.aspx
Wednesday, May 3, 2017
Is the current user a local admin?
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] “Administrator”))
{
Write-Warning “<ERROR MESSAGE GOES HERE>”
Break
}
[Security.Principal.WindowsBuiltInRole] “Administrator”))
{
Write-Warning “<ERROR MESSAGE GOES HERE>”
Break
}
Tuesday, May 2, 2017
Down the Rabbit Hole- A Study in PowerShell Pipelines, Functions, and Parameters
https://www.simple-talk.com/dotnet/net-tools/down-the-rabbit-hole-a-study-in-powershell-pipelines-functions-and-parameters/
Get Directory Listing and Output to CSV
$reportsFolder='<STARTING PATH GOES HERE>' `
Get-ChildItem -Path $reportsFolder -Recurse -Include "*.rpt" | `
Select-Object DirectoryName,Name,LastWriteTime | `
Where-Object -FilterScript {($_.LastWriteTime -ge "2016-01-01")} | `
Export-CSV -Path "C:\temp\CrystalReportFiles.csv" -Encoding ascii -NoTypeInformation
Get-ChildItem -Path $reportsFolder -Recurse -Include "*.rpt" | `
Select-Object DirectoryName,Name,LastWriteTime | `
Where-Object -FilterScript {($_.LastWriteTime -ge "2016-01-01")} | `
Export-CSV -Path "C:\temp\CrystalReportFiles.csv" -Encoding ascii -NoTypeInformation
Subscribe to:
Comments (Atom)