Advertisement
Guest User

Untitled

a guest
Dec 12th, 2016
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. New-WebServiceProxy : The request failed with HTTP status 401: Unauthorized.
  2. At C:ScriptsGetItemID_UsingWebServices.ps1:1 char:26
  3. + $WS = New-WebServiceProxy <<<< -uri http://server/sites/promo/_vti_bin/SiteData.asmx
  4. + CategoryInfo : ObjectNotFound: (http://server...n/SiteData.asmx:Uri) [New-WebServiceProxy], WebExcept
  5. ion
  6. + FullyQualifiedErrorId : WebException,Microsoft.PowerShell.Commands.NewWebServiceProxy
  7. Property 'Credentials' cannot be found on this object; make sure it exists and is settable.
  8. At C:ScriptsGetItemID_UsingWebServices.ps1:2 char:5
  9. + $WS. <<<< Credentials = [System.Net.CredentialCache]::DefaultCredentials
  10. + CategoryInfo : InvalidOperation: (Credentials:String) [], RuntimeException
  11. + FullyQualifiedErrorId : PropertyNotFound
  12.  
  13. You cannot call a method on a null-valued expression.
  14. At C:ScriptsGetItemID_UsingWebServices.ps1:12 char:26
  15. + $GUS = $WS.GetURLSegments <<<< ($ItemURL, $webID, $bucketID, $strListID, $strItemID)
  16. + CategoryInfo : InvalidOperation: (GetURLSegments:String) [], RuntimeException
  17. + FullyQualifiedErrorId : InvokeMethodOnNull
  18.  
  19. $WS = New-WebServiceProxy -uri http://server/_vti_bin/SiteData.asmx
  20. $WS.Credentials = [System.Net.CredentialCache]::DefaultCredentials
  21. #$WS.Credentials = [System.Net.NetworkCredential]::("user", (ConvertTo-SecureString "password" -AsPlainText -force), "domain")
  22. $ItemURL = "http://server/sites/promo/sales/testLib/TestFile.txt"
  23. $GUS = $WS.GetURLSegments($ItemURL, $webID, $bID, $strListID, $strItemID)
  24. Write-Host $strItemID
  25.  
  26. $webID = $null
  27. $bID = $null
  28. $strListID = $null
  29. $strItemID = $null
  30. $GUS
  31. $uri = "http://Server/sites/Promo/TestDocLibrary44/_vti_bin/SiteData.asmx"
  32. $WS = New-WebServiceProxy -uri $uri -UseDefaultCredential
  33. $ItemURL = "http://Server/sites/Promot/TestDocLibrary44/2011102100006b.pdf"
  34. $GUS = $WS.GetURLSegments($ItemURL, [REF]$webID, [REF]$bID, [REF]$strListID, [REF]$strItemID)
  35. write-Host $strItemID.value # returning null or blank
  36. write-Host $webID # returning null or blank
  37. Write-Host "Test "
  38.  
  39. $WS.Credentials = [System.Net.NetworkCredential]::("USERNAME", (ConvertTo-SecureString "PASSWORD" -AsPlainText -force))
  40.  
  41. $WS.Credentials = [System.Net.NetworkCredential]::("USERNAME", (ConvertTo-SecureString "PASSWORD" -AsPlainText -force), "DOMAIN")
  42.  
  43. $WS = New-WebServiceProxy -uri http://server/sites/promo/sales/_vti_bin/SiteData.asmx
  44. $WS.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
  45. $ItemURL = "http://server/sites/promo/sales/testLib/TestFile.txt"
  46. $GUS = $WS.GetURLSegments($ItemURL, $webID, $bID, $strListID, $strItemID)
  47. Write-Host $strItemID
  48.  
  49. $username = "username"
  50. $password = "password"
  51.  
  52. $cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))
  53.  
  54. #assign $cred to the webServicesProxy.Credentials
  55. $webServicesProxy.Credentials = $cred
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement