About SQL Provider

Welcome Forums General PowerShell Q&A About SQL Provider

This topic contains 2 replies, has 1 voice, and was last updated by

 
Participant
2 years, 6 months ago.

  • Author
    Posts
  • #55232

    Participant
    Points: 0
    Rank: Member

    Hello,

    I have a question about how providers work beyond the explanation of the extensive help file both online and in powershell help system.
    Each time, in my function when i invoke Invoke-Sqlcmd, if in the following lines the command are about file system provider, it fails because after the precedent command ran, it stays in SQLSERVER:\> provider prompt.
    The Workaround that i found, is to Set-Location to C:\> immediately after those commands. Is this a proper way of handling this? Is there a better way to do it? I tried and failed, using Push-Location and Pop-Location in the function not sure if i had a glimpse of cleverness. Please find below a few lines of the function:

    #Variable
    $bic= random ID
    $DRMaster = SRV1
    $DRSlave = SRV2
    $DRbicdir = folderonfirstserver
    $DRbicdir2 = folderonsecondserver
    
    #DB configuration
       Invoke-sqlcmd -InputFile "$DRbicdir2\__04_On_Primary_Set_DR_DB_srv1.sql" -ServerInstance "$DRSlave" -ErrorAction Stop
             Write-Host "trax_$bic is now set as the secondary log shipping FAILOVER database on $DRSlave" -ForegroundColor Green
    
    # Checking DB on $DRMaster is ONLINE in the DR solution.
    (Set-Location $DRbicdir)
    $testFODB = else { $false }
    

    Thanks for your feedbacks on this!
    Cheers!

  • #55237

    Participant
    Points: 0
    Rank: Member

    Please excuse the quickness of my parsing code. Below is the entire version:

    Thanks for you inputs!!
    Cheers.

  • #55241

    Participant
    Points: 0
    Rank: Member

    Better have the gist url, as the formatting is messed up. here it's:
    Gist Code
    Sorry about that.

The topic ‘About SQL Provider’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort