Avatar of Auerelio Vasquez
Auerelio VasquezFlag for United States of America

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)

#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)" }

Open in new window


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 ?
PowershellMicrosoft SQL Server 2008

Avatar of undefined
Last Comment
lcohan
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Microsoft SQL Server 2008
Microsoft SQL Server 2008

Microsoft SQL Server 2008 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. Major improvements include the Always On technologies and support for unstructured data types.

50K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo