Auerelio Vasquez
asked on
Powershell __Insert rows to a sql table if a condition occurs
Hi,
Im' very new to Powershell, in fact this is the first time I've ever tried to use it. I figured out how to move a file, if it's named a certain way, that was pretty easy (Code below)
so, what I'm trying to do from this now, is to create a job in SQL Server that runs this powershell script. Then i'll run the job from an ssis package and orchestrate everything in SSIS
what I want to know if is possible
if the script moves the file.....insert a 'Y' Flag and the filename into a sql server table.....
if it doesn't just end (no big deal)
Is any of this possible ?
Im' very new to Powershell, in fact this is the first time I've ever tried to use it. I figured out how to move a file, if it's named a certain way, that was pretty easy (Code below)
#the directory the file is in
$path_in = "D:\Projects\OTS\Agent Skill Group\Data"
#the directory the file will be moved to
$path_out = "D:\Projects\OTS\Agent Skill Group\Archive"
#get the conteents of $path_in
$contents = Get-ChildItem $path_in
#where name ends with _nodata.csv
$contents_with_nodata = $contents | ? { $_.Name -match "_nodata.csv$" }
#for each item in $contents_with_nodata
$contents_with_nodata | % { mv $_.Name "$($path_out)\$($_.Name)" }
#pipe the output of each expression into the next expression
#$contents = Get-ChildItem $path_in | ? { $_.Name -match "_nodata.csv" } | % { mv $_.Name "$($path_out)\$($_.Name)" }
so, what I'm trying to do from this now, is to create a job in SQL Server that runs this powershell script. Then i'll run the job from an ssis package and orchestrate everything in SSIS
what I want to know if is possible
if the script moves the file.....insert a 'Y' Flag and the filename into a sql server table.....
if it doesn't just end (no big deal)
Is any of this possible ?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.