Find Jobs
Hire Freelancers

Powershell/SQL run script in background

€8-30 EUR

Cancelled
Posted over 7 years ago

€8-30 EUR

Paid on delivery
This is the sql trigger: BEGIN --SP declare @cmd nvarchar(2000) declare @folder nvarchar(200) SET @folder = ''''+'"'+(SELECT CAST(Project_ID as nvarchar)+' '+Name FROM Project WHERE Project_ID=@projID)+'"'+'''' set @cmd = 'powershell "D:\PS\[login to view URL]"'+' ' +@folder exec master.dbo.xp_cmdshell @cmd END --SP This is script that works when called from sql but takes very long to finish: param( [Parameter(Position=0, Mandatory=$true)] [string]$FolderName ) $username = "mg@[login to view URL]" $PasswordFile = "D:\PS\Passwords\[login to view URL]" $KeyFile = "D:\PS\Passwords\[login to view URL]" $key = Get-Content $KeyFile $UserCred = New-Object [login to view URL] ($username, (Get-Content $PasswordFile | ConvertTo-SecureString -Key $key)) $NetWorkCred = New-Object [login to view URL]($username , (Get-Content $PasswordFile | ConvertTo-SecureString -Key $key)) $Session = New-PSSession -ConfigurationName [login to view URL] -ConnectionUri [login to view URL] -Credential $UserCred -Authentication Basic -AllowRedirection Import-Module D:\PS\[login to view URL] Create-Folder -MailboxName prosjekt@[login to view URL] -Credentials $NetWorkCred -NewFolderName $FolderName -ParentFolder '\Innboks' Import-PSSession $Session $ProjectNo = $[login to view URL](0,4) New-InboxRule -Name $ProjectNo -Mailbox prosjekt@[login to view URL] -SubjectOrBodyContainsWords "PREFAB$ProjectNo" -MoveToFolder ":\Innboks\$FolderName" -StopProcessingRules $true -confirm:$false -Force Remove-PSSession $Session This is script that works when executed locally on server and works in background, but it does not work when called from sql trigger: param( [Parameter(Position=0, Mandatory=$true)] [string]$FolderName ) $createFolderAndRule = { param([string]$FolderName) $username = "mg@[login to view URL]" $PasswordFile = "D:\PS\Passwords\[login to view URL]" $KeyFile = "D:\PS\Passwords\[login to view URL]" $key = Get-Content $KeyFile $UserCred = New-Object [login to view URL] ($username, (Get-Content $PasswordFile | ConvertTo-SecureString -Key $key)) $NetWorkCred = New-Object [login to view URL]($username , (Get-Content $PasswordFile | ConvertTo-SecureString -Key $key)) $Session = New-PSSession -ConfigurationName [login to view URL] -ConnectionUri [login to view URL] -Credential $UserCred -Authentication Basic -AllowRedirection Import-Module D:\PS\[login to view URL] Create-Folder -MailboxName prosjekt@[login to view URL] -Credentials $NetWorkCred -NewFolderName $FolderName -ParentFolder '\Innboks' Import-PSSession $Session $ProjectNo = $[login to view URL](0,4) New-InboxRule -Name $ProjectNo -Mailbox prosjekt@[login to view URL] -SubjectOrBodyContainsWords "PREFAB$ProjectNo" -MoveToFolder ":\Innboks\$FolderName" -StopProcessingRules $true -confirm:$false -Force Remove-PSSession $Session } Start-job -ScriptBlock $createFolderAndRule -Argumentlist $FolderName
Project ID: 11656214

About the project

3 proposals
Remote project
Active 7 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
3 freelancers are bidding on average €372 EUR for this job
User Avatar
Hi. We are ready to do this for you as per your requirement. You can check the reviews and can make out that we only do quality work. We are very sure that we will earn your 5 star review for this project. Looking forward to work with you! TechyMonkey
€400 EUR in 7 days
0.0 (0 reviews)
0.0
0.0
User Avatar
We have 12 Years Experienced in PHP, HTML, CSS, MySQL, Wordpress, Apache, Server .Net ( C# and Vb.Net ) Android & IOS etc am really good at fixing errors and bugs. I always think outside the box to provide the best results to my clients and make them happy each time they hire me. I love to solve problems, create great ideas and execute them accordingly.
€555 EUR in 10 days
0.0 (0 reviews)
0.0
0.0
User Avatar
Hello Sir, I understood that you are looking for Experienced SQL developer. Can you please share your best time for the chat so we can discuss further and move ahead. We have team of experienced DBA/Developer and we can easily do this task. Thanks, Vijay Thakor
€311 EUR in 5 days
0.0 (0 reviews)
0.0
0.0

About the client

Flag of NORWAY
Bjerkreim, Norway
4.8
5
Payment method verified
Member since Aug 20, 2016

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.