Database Reference
In-Depth Information
The PowerShell proile
If you inspect $profile in PowerShell you'll get back a proile ilename where common script
will be loaded automatically whenever you start a PowerShell session:
PS > $profile
C:\Users\Geoff\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.
ps1
You could dot source these common script libraries inside the proile script so they are
included automatically when starting PowerShell. You might even invoke some functions
afterwards such as Load-ODP . These iles do not exist by default and there is a different
proile for each host; for example the ISE uses a Microsoft.PowerShellISE_profile.
ps1 ilename. You may want to create and dot source a SharedProfile.ps1 ile that
deines the shared proile script for all hosts.
Script automation and error handling
(Medium)
In this script we'll look at automating a PowerShell script with a scheduled task, logging, and
error handling. We will query employee data where the commission percentage exceeds a given
threshold and export that data to a CSV ile for later analysis.
Getting ready
Complete the previous recipes irst. Copy updated versions of Oracle.DataAccess.ps1
and Utilities.ps1 from the sample code iles for this chapter that includes parameter
support in Get-ODPDataTable and a new function Get-CanTranscribe . Likewise copy
App.config and change the connection string as necessary.
How to do it...
1.
Create a Query.sql ile to deine the SQL we want to execute:
select
e.employee_id,
e.first_name || ' ' || e.last_name employee,
e.email,
e.hire_date,
e.job_id,
e.salary,
e.commission_pct,
d.department_name department
from
 
Search WWH ::




Custom Search