Powershell/SQL run script in background €8-30 EUR Publicado hace más de 7 años
€8-30 EUR Pagado a la entrega
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
ID del proyecto: 11656214
Información sobre el proyecto 3 propuestas
Proyecto remoto
Activo hace 8 años
¿Buscas ganar dinero? Dirección de email Postular a trabajos similares Beneficios de presentar ofertas en Freelancer Fija tu plazo y presupuesto
Es gratis registrarse y presentar ofertas en los trabajos
3 freelancers están ofertando un promedio de €372 EUR por este trabajo
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 en 7 días
0,0 (0 comentarios) 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 en 10 días
0,0 (0 comentarios) 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 en 5 días
0,0 (0 comentarios)