examples/01-Quick-Start.ps1
|
# 01 - Quick start: a new Access database, a table with an AutoNumber key, rows in, rows out. 30 seconds, no Access. # Runs on Windows, Linux and macOS with PowerShell 7.2+: Install-PSResource kAccess; ./01-Quick-Start.ps1 Import-Module kAccess $Folder = Join-Path ([IO.Path]::GetTempPath()) 'kAccess-examples' New-Item $Folder -ItemType Directory -Force | Out-Null $Db = Join-Path $Folder 'QuickStart.accdb' Remove-Item $Db -ErrorAction Ignore New-kAccessDatabase $Db | Out-Null New-kAccessTable $Db Contacts -Column @{ Name = 'Id'; Type = 'LONG'; AutoNumber = $true }, @{ Name = 'Name'; Type = 'TEXT'; Length = 60 }, @{ Name = 'Email'; Type = 'TEXT'; Length = 120 }, @{ Name = 'Added'; Type = 'SHORT_DATE_TIME' } ` -Index @{ Name = 'PrimaryKey'; Columns = @('Id'); PrimaryKey = $true } Add-kAccessRow $Db Contacts -Row @{ Name = 'Ada Lovelace'; Email = 'ada@example.com'; Added = Get-Date }, @{ Name = 'Alan Turing'; Email = 'alan@example.com'; Added = Get-Date } Get-kAccessRow $Db Contacts | Format-Table Id, Name, Email, Added "Database: $Db - open it in Microsoft Access if you have it, it is an ordinary .accdb file." |